Jessica Mays wrote:
    From:       [EMAIL PROTECTED]
    Subject:     problem with a while loop
    Date:     May 6, 2004 11:25:28 AM EDT
    To:       [EMAIL PROTECTED]

Hey everybody!

I am new to php (and mySQL) and I am working on a php page that links up to a mySQL database. My current code works up to a point, BUT what happens is that I try to have a while loop and check a variable with an inner while loop but it only catches after the first complete cycle.

Basically, some producers will only call up one row, but you always get 2 at the minimum with this code below. I have tried lots of different things which all lead to the second row endlessly repeating or the page not loading at all.

Any ideas?  Please email me directly since I am on the digest. Thanks
Jessica

(Also, I am new to this list and if this email is in the wrong format I apologize.)

CODE :

<?

$query = "select * from wine where REGION like 'California' order by PRODUCE,DESCRIPT,VINTAGE";

  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);

  echo "<p>Number of wines found: ".$num_results."</p>";

  $i =0;

  while ($i < $num_results)   {

        $row = mysql_fetch_array($result);

$producer = $row["PRODUCE"];
<snip>

Try changing the above from....

while ($i < $num_results)   {

        $row = mysql_fetch_array($result);

To....

while ( $row = mysql_fetch_array($result) ) {


-- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to