Say for example this is my code:
$query = "SELECT * FROM ...";
$exec_query = mysql_query($query, $db_connect);
$fetchdetails = mysql_fetch_array($exec_query);
I am using an if condition like this:
if ($fetchdetails['field_name'] == 3) {
do something;
}
else {
}
But in this, only 1 row is compared from the fetchdetails array. What can I do to compare each row in that array with 3? I don’t want any OOP’s solutions, please, I want to stick with traditional coding. Thank you.
You should try this:
That’s because, with the
while(...)condition, you’ll iterate over all db (selected) records.The loop will stop in an automatic way as soon as
mysql_fetch_arrayfinish record.I’ll remember you that
mysql_fetch_arrayand that will allow “you” to stop iteration process.