Re: while loop

From: Date: Tue, 10 Apr 2001 06:58:29 +0000
Subject: Re: while loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47972@lists.php.net to get a copy of this message
What does this do : <?php error_reporting(E_ALL); $q = "SELECT * FROM MiniOffers WHERE hotel_id = '$hotelID' ORDER BY start_date ASC"; $r = mysql_query($q); if ($r == true) { while ($row = mysql_fetch_array($r)) { echo $row['start_date'] .'<br>'; } } else { echo ' no result '. mysql_error(); } ?> Regards, Philip On Tue, 10 Apr 2001, Jacky@lilst wrote: > Here I got this script: > > $queryoffers = "SELECT * FROM MiniOffers WHERE hotel_id = '$hotelID' ORDER > BY start_date ASC"; > $resultofrs = mysql_query($queryoffers, $connection) or die(mysql_error()); > > while($row = mysql_fetch_array($resultofrs)) > > > $IsAva = $row[6]; > } > > and it keep saying "maximum execution time exceeded 30 secs", am I doing > something time consuming here? There are only 2 records in the table. > cheers > Jack > jacky@activelifestyle.com > "There is nothing more rewarding than reaching the goal you set for > yourself" > ----- Original Message ----- > From: Zeus <techzeus@pacific.net.sg> > To: <huntsman@www.nisu.flinders.edu.au>; Michael Hall <lists@mulga.com.au>; > Jacky <jacky@activelifestyle.com> > Cc: <php-general@lists.php.net> > Sent: Tuesday, April 10, 2001 12:58 AM > Subject: Re: [PHP] while loop > > > > Isn't the '=' operator suppose to be used for assigning and not for > > evaluation. > > > > I thought '==' should be used in this context? > > > > Zeus > > ----- Original Message ----- > > From: David Robley <huntsman@www.nisu.flinders.edu.au> > > To: Zeus <techzeus@pacific.net.sg>; Michael Hall <lists@mulga.com.au>; > Jacky > > <jacky@activelifestyle.com> > > Cc: <php-general@lists.php.net> > > Sent: Tuesday, 10 April, 2001 1:53 PM > > Subject: Re: [PHP] while loop > > > > > > > On Tue, 10 Apr 2001 15:16, Zeus wrote: > > > > > $query = mysql_query("some SQL here"); > > > > > while ($row = mysql_fetch_array($query)) { > > > > > do stuff; > > > > > } > > > > > > > > Isn't this suppose to be an infinite loop? > > > > > > > > while ($row is assigned to mysql_fetch_array($query)) { > > > > do stuffs; > > > > } > > > > > > > > someone correct me if I'm wrong? > > > > > > > > Zeus > > > > > > Consider yourself corrected :-) mysql_fetch-array returns an array > > > corresponding to the fetched row, or _false if there are no more rows_ > > > > > > So as soon as there are no more rows, $row = mysql_fetch_array($query) > > > evaluates to false and the while exits. > > > > > > -- > > > David Robley | WEBMASTER & Mail List Admin > > > RESEARCH CENTRE FOR INJURY STUDIES | > > > http://www.nisu.flinders.edu.au/ > > > AusEinet | > > > http://auseinet.flinders.edu.au/ > > > Flinders University, ADELAIDE, SOUTH AUSTRALIA > > > > > > -- > > 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 > > > > > > > -- > 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 (#47972) next »