note 16945 added to control-structures.while
| From: | andrew at andysplayground dot com | Date: | Mon, 19 Nov 2001 22:33:21 +0000 |
| Subject: | note 16945 added to control-structures.while | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21030@lists.php.net to get a copy of this message | ||
I was looping through some results from my DB and wanted to tell the user if there were no results,
so I wrote this:
$i = 1;
while ($record = mysql_fetch_array($result)) {
print "\t\t $record[0] \n";
$i = $i + 1;
}
//i = 1 if there were no results because we never went through the loop
if ($i==1){
echo "<em>no results</em>";
}
--
http://www.php.net/manual/en/control-structures.while.php
http://master.php.net/manage/user-notes.php?action=edit+16945
http://master.php.net/manage/user-notes.php?action=delete+16945
http://master.php.net/manage/user-notes.php?action=reject+16945