Hi all
question about how to test for the result of a mysql_fetch_array as the condition of a while loop.
what I want to do is fetch the data from the mysql resource, and then either get a message that it is empty (no data in row), or if there is data, do stuff with the data.
example:
$stmp=mysql_query(select * from mytable where thevalue=1);
while ($row=mysql_fetch_array($stmp)){
foreach ($row as $data)
{
do some stuff
}
}#end of the whileloop
however, if the msql query produces nothing (eg there are nothing in mytable that matches thevalue) what is the returned value of $row?
I know one way to fix this, but it requires another mysql call, and I'd rather not have to add another mysql call just to test if there is data or not.
eg:
if (mysql_fetch_array($stmp){
do the above code
}else{
echo "no data returned";
}
or something like this.
any ideas or help on this would be much appreciated.
thanks
eric