Re: Loops

From: Date: Tue, 14 Dec 2004 16:27:01 +0000
Subject: Re: Loops
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204304@lists.php.net to get a copy of this message
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

« previous php.general (#204304) next »