Portal Home > Knowledgebase > Articles Database > Simple php mysql select question


Simple php mysql select question




Posted by lexington, 09-27-2007, 07:12 PM
I guess after the nonstop coding my brain has given up on me since I cannot figure this out. Could anyone provide me with an example that selects every row from a mysql DB table, and checks to see if each result is equal to 1? I am trying to add an error check to see if every row table named im_ready is equal to 1 and if not then it will stop the script. I cannot figure out a way to write this since a simple select query will not do the trick. Is there were foreach comes in or something? If you could please provide me with a code example that selects into from a DB and checks each individual value for each row and if one is not equal to 1 it errors but if all equal 1 it goes. I did use a SELECT count that compares the total rows to the rows that are ready and if they are equal it does what I want but the code looks messy and I am sure there is a better and cleaner way. Thanks. Last edited by lexington; 09-27-2007 at 07:15 PM.

Posted by foobic, 09-27-2007, 08:16 PM
What's the table structure? Any reason you can't do this?

Posted by lexington, 09-27-2007, 08:22 PM
Yeah actually that is how I had originally programmed it. It works but is that the only way to go about it? I figured there was a simple built in php function that can do this a better way. If not then no worries and thanks for your reply. Last edited by lexington; 09-27-2007 at 08:34 PM.

Posted by foobic, 09-27-2007, 08:39 PM
It's a single query returning a single result. How much simpler do you want it to be?

Posted by lexington, 09-27-2007, 08:42 PM
It just looks messy the way I have it since I have to have one query counting how many are equal to one, and another query counting how many are in the room. Ok well you answered my question then thanks



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

Language: