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

From: Date: Tue, 03 Apr 2001 13:07:03 +0000
Subject: RE: [PHP-DB] How to limit a WHILE statement?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8179@lists.php.net to get a copy of this message
Yes, LIMIT will do the job, but to answer your question: $x = 0; while ( ( $myrow = mysql_fetch_array( $result ) ) and ( ++$x < 20 ) ) { [...] } Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - _______________________________________________________________ Suchtreffer AG Bleicherstraße 20 D-78467 Konstanz Germany fon: +49-(0)7531-89207-17 fax: +49-(0)7531-89207-13 e-mail: mailto:mru@suchtreffer.de internet: http://www.suchtreffer.de _______________________________________________________________ > -----Original Message----- > From: Bob Stone [mailto:bstone98@yahoo.com] > Sent: Tuesday, April 03, 2001 12:53 AM > To: php-db@lists.php.net > Subject: [PHP-DB] 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 Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.db (#8179) next »