I am using an api that comes back in JSON and in i guess called "pairs". excuse me if that is the wrong terminology
I am then searching thru looking the json that comes back for a specific user ID. which happens to be the second of the two pairs.
I am looking to get the balance of the id
so the JSON comes Back like this:
{"balance":"104","id":"2264511436216725766"},
{"balance":"100","id:"13430408307535451875"},
{"balance":"160","id":"4496198869167276848"},
This is what i am using now:
$set="4496198869167276848";
foreach($result['Balances'] as $key=>$value){
$qty = number_format($value['balance'] / 100000, 4);
$ID= $value['id'];
if($ID == $set){
$sql = "UPDATE $table SET meta_value='$qty' WHERE user_id = '$user' AND meta_key = 'default_total' ";
if ($conn->query($sql) === TRUE) {
// echo "Record updated successfully";
} else {
// echo "Error updating record: " . $conn->error;
}
break;
} else {
$msg="<strong style='text-decoration:none;color:#289dcc;font-weight:bold'>ERROR !!! It Looks like you do not Have any Shares</strong><br>";
echo $msg;
break;
}
}
well what is happening is it only showing the 1st balance which is 104
I need it to stop once it finds it so i put the break;
without it will show the error message.
"aroundidin second data of JSON here:-{"balance":"100","id:"13430408307535451875"},is it a typo?