No MySQL Results
Hey, this is probably a pretty easy question....but when you're looping through data by row to print on a page....and there are no rows, how do you return a value that says that, so you can display a message accordingly?
Thanks
Hey, this is probably a pretty easy question....but when you're looping through data by row to print on a page....and there are no rows, how do you return a value that says that, so you can display a message accordingly?
Thanks
KarenArt posted this at 14:34 — 18th August 2004.
She has: 354 posts
Joined: May 2001
Is this what you mean?
$i = count($data);
if ($i > 0) {
RUN LOOP FOR PRINTING DATA
} else {
print "Message to display if count = 0";
}
gotta finish redesigning my sites so I can show them again.
The purpose of education is... to get more jokes!
Suzanne posted this at 21:19 — 18th August 2004.
She has: 5,507 posts
Joined: Feb 2000
you can also test for numrows
if ($mysql_numrows == 0) {
echo "ACK NOTHING HERE!";
}
Check php.net for the variable name in case I have something askew, I'm just typing without reference at the moment.
kb posted this at 21:45 — 18th August 2004.
He has: 1,380 posts
Joined: Feb 2002
ok...i didnt' even think of that...DOH
Thanks
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.