Re: The Do...While Diddy or How to exit a routine...

From: Date: Sat, 01 Jul 2000 23:38:16 +0000
Subject: Re: The Do...While Diddy or How to exit a routine...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4321@lists.php.net to get a copy of this message
Your right Ian, Use a break; instead of exit; Comron ----- Original Message ----- From: "Digital Hit Entertainment" <ianevans@friedspamdigitalhit.com> To: <php-general@lists.php.net> Sent: Saturday, July 01, 2000 4:15 PM Subject: [PHP] The Do...While Diddy or How to exit a routine... > Well, I was proud of myself that I was able to code a news page with > next/prev buttons with odbc. I wanted to put a list of the five most > recent headlines on the page. The query worked fine. > > However, that excitement was tempered by the fact that I can't seem to > code a statement that will fetch results of a query until either they > end or reach 5 lines, whichever comes first. Right now my code is this: > > <? > $topnews=1; > $connect = odbc_connect("blah", "blah", "blah"); > $query = "SELECT headline, date FROM news ORDER BY date DESC"; > $result = odbc_do($connect, $query); > while (odbc_fetch_row($result)) > { > $headline = odbc_result($result, headline); > echo ("$headline<br /><br />\n"); > $topnews++; > if ($topnews = 5) { > odbc_close($connect); > exit; > } > } > odbc_close($connect); > ?> > > Right now the code displays the headline but doesn't display the rest of > the page that comes after the ?>. From scouring the manual I see that > exit may be my culprit. What else would work and is there a way to make > the code a little more compact. > > Having fun coding parts of the site with PHP and love the advice I've > been reading here. Thanks in advance. > -- > Ian Evans > > -- > 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 > > ----- Original Message ----- From: "Digital Hit Entertainment" <ianevans@friedspamdigitalhit.com> To: <php-general@lists.php.net> Sent: Saturday, July 01, 2000 4:15 PM Subject: [PHP] The Do...While Diddy or How to exit a routine... > Well, I was proud of myself that I was able to code a news page with > next/prev buttons with odbc. I wanted to put a list of the five most > recent headlines on the page. The query worked fine. > > However, that excitement was tempered by the fact that I can't seem to > code a statement that will fetch results of a query until either they > end or reach 5 lines, whichever comes first. Right now my code is this: > > <? > $topnews=1; > $connect = odbc_connect("blah", "blah", "blah"); > $query = "SELECT headline, date FROM news ORDER BY date DESC"; > $result = odbc_do($connect, $query); > while (odbc_fetch_row($result)) > { > $headline = odbc_result($result, headline); > echo ("$headline<br /><br />\n"); > $topnews++; > if ($topnews = 5) { > odbc_close($connect); > exit; > } > } > odbc_close($connect); > ?> > > Right now the code displays the headline but doesn't display the rest of > the page that comes after the ?>. From scouring the manual I see that > exit may be my culprit. What else would work and is there a way to make > the code a little more compact. > > Having fun coding parts of the site with PHP and love the advice I've > been reading here. Thanks in advance. > -- > Ian Evans > > -- > 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 (#4321) next »