mercredi 20 mai 2015

How to check if all rows match a criteria in PHP

I want to check if a certain field of all rows match a criteria. So if all rows has in the Status field 'RUN' as value then echo "Success". If there is one row with END as value then echo "Fail":

I'm guessing I need a loop and an IF statement ? I was thinking something like this but it doesnt return anything:

while($source_row = mysqli_fetch_array($source_selection)){
if ( ($source_row['Stat']) == ("Run" ) {
echo "Success<br />";
} else echo "Fail";
}

I dont want to echo each row, I want all rows to match a criteria then echo, if one doesnt match a criteria then echo as well.

Aucun commentaire:

Enregistrer un commentaire