Re: [PHP-DB] problem with WHILE loop

2001-10-01 Thread Eric J Schwinder

Thanks to everyone who replied either here or via e-mail... I got a lot of
great suggestions. I ended up solving the WHILE problem by changing this:

 $list = mysql_query(select id,title from table1);
 $list_row = mysql_fetch_array($list);
 $title = $list_row[title];

 while($list_row) {
 echo($title br\n);
 }

to this:

   $list = mysql_query(select id,title from table1);
   $title = $list_row[title];

   while($list_row = mysql_fetch_array($list)) {
   echo($title br\n);
   }


Eric Schwinder
eric.AT.bergencomputing.DOT.com
AT = @
DOT = (well... you know)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] problem with WHILE loop

2001-10-01 Thread BoNzO

$list = mysql_query(select id,title from table1);
while ($row = mysql_fetch_array($list)) {
echo($row[title]br\n);
}

-Original Message-
From: Eric J Schwinder
[mailto:[EMAIL PROTECTED]] 
Sent: den 1 oktober 2001 20:18
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] problem with WHILE loop

Thanks to everyone who replied either here or via e-mail... I got a lot
of
great suggestions. I ended up solving the WHILE problem by changing
this:

 $list = mysql_query(select id,title from table1);
 $list_row = mysql_fetch_array($list);
 $title = $list_row[title];

 while($list_row) {
 echo($title br\n);
 }

to this:

   $list = mysql_query(select id,title from table1);
   $title = $list_row[title];

   while($list_row = mysql_fetch_array($list)) {
   echo($title br\n);
   }


Eric Schwinder
eric.AT.bergencomputing.DOT.com
AT = @
DOT = (well... you know)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] problem with WHILE loop

2001-09-30 Thread Jason G.

the mysql_query function returns a Result Identifier.  For every row in the 
result (found by mysql_num_rows), you must call one of the the row 
retrieval functions (mysql_fetch_array, mysql_fetch_object, etc...)  These 
functions automatically advance the row position in the Result.

Replace the code with this:

?php

   $dbResult = mysql_query(select id,title from table1);
   $nRowCount = mysql_num_rows($dbResult);

   for($i=0; $i$nRowCount; $i++)
   {
 $aRow = mysql_fetch_array($dbResult);
 $title = $list_row[title];
 echo($title br\n);
   }

?

-Jason Garber
www.ionzoft.com

*
I prefer mysql_fetch_object() personally...

Replace the code with this:

?php

   $dbResult = mysql_query(select id,title from table1);
   $nRowCount = mysql_num_rows($dbResult);

   for($i=0; $i$nRowCount; $i++)
   {
 $oRow = mysql_fetch_object($dbResult);
 echo($oRow-title br\n);
   }

?




At 08:32 PM 9/30/2001 -0500, you wrote:
I have the following code on a page:

?php
   $list = mysql_query(select id,title from table1);
   $list_row = mysql_fetch_array($list);
   $title = $list_row[title];

   while($list_row)  {
   echo($title br\n);
   }
?

For some reason, when I load the page, instead of a list of the titles from
table1, I get the title from the first row of table1 repeated over and over.

Obviously I'm doing something wrong, and it's probably something really
dumb, right in front of my face... but I can't find it!  help?

Thanks,

Eric Schwinder
eric.AT.bergencomputing.DOT.com
 AT = @
 DOT = (well... you know)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]