RE: [PHP] How to limit a WHILE statement?

From: Date: Mon, 02 Apr 2001 22:57:05 +0000
Subject: RE: [PHP] How to limit a WHILE statement?
Groups: php.general 
Request: Send a blank email to php-general+get-46699@lists.php.net to get a copy of this message
Probably a more efficient way to do this is to put a LIMIT qualifier on your query (see the MySQL docs). Then you won't retrieve rows you are not going to use anyway. Kirk > -----Original Message----- > From: Bob Stone [mailto:bstone98@yahoo.com] > Sent: Monday, April 02, 2001 4:54 PM > To: php-general@lists.php.net > Subject: [PHP] How to limit a WHILE statement? > > > Dear PHP Helpers, > > What is your recommendation on limiting a while > statement so that it only iterates a maximum of 20 > times? > > Here is the code snippet: > > $result = mysql_query($sql, $db); > > while ($myrow = mysql_fetch_array($result)) { > > printf("Name: <b><font color=\"green\" size=\"5s\">%s > %s %s %s\n<br></b></font>", $myrow["salutation"], > $myrow["first_name"], $myrow["mid_name"], > $myrow["user_name"]); > > Best regards, > > Bob Stone > > __________________________________________________ > Do You Yahoo!? > Get email at your own domain with Yahoo! Mail. > http://personal.mail.yahoo.com/?.refer=text > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#46699) next »