Re: Loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Steve,

Tuesday, December 14, 2004, 3:52:26 PM, you wrote:

SM> I would like to loop the multiple variables rather than put all the
SM> variables into a single variable with an array. I can not figure out how to
SM> do this.

I assume you have placed the MySQL query and checked the number of
rows it has returned? You could just do:

while ($row == mysql_fetch_assoc($result))
{
      $name = $row['name'];
      $desc = $row['description'];

      echo "$name <br />";
      echo "desc <br />";
}

This is just one of many ways of performing the same task. You could
use a for() loop based on mysql_num_rows, you could use fetch_array
instead of assoc. If you are only extracting a couple of details then
you could even use mysql_result($result, $record, 'name'). I would
suggest you take a look in the PHP manual, there are many examples of
this.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux