Page 1 of 1

if "a" or "b" or "c" then &quo

Posted: Sat Dec 31, 2005 3:42 am
by atronmania
Hi everyone, I'm a newbie so don't laugh ;-)

I have a database with the following rows:
['a01_01']
['a01_02']
['a01_03']
['a01_04']
and each of these rows have a value of 1 or 0

Here is the question, how should i write a condition for this:
if "one of the rows are == 1"
it should echo"something"

thanks in advance!

Posted: Sat Dec 31, 2005 3:49 am
by djot
-
Do you mean rows (datasets) or columns (table fields)?


Guess you mean columns, you would read your data into an array and then either loop through the array or check array for including data:

looping (guessed you fetched the array into $row):

Code: Select all

foreach ($row AS $key =>  $value) {
if ($value == 1) {
// do something
break; // stop looping
}
}
checking, if '1' is in the array:

Code: Select all

if (in_array("1", $row)) {
// do something
}
djot
-

Posted: Sat Dec 31, 2005 9:00 am
by atronmania
in_array worked perfect!!
Thanks alot