Re: Loops
| From: | Richard Lynch | Date: | Tue, 14 Dec 2004 16:31:16 +0000 |
| Subject: | Re: Loops | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204305@lists.php.net to get a copy of this message | ||
Steve Marquez wrote:
> Greetings. I am trying to display looped information from a MySQL database
> in a PHP file.
>
> Loop
>
> $name (witht a br />) then
> $description
>
> End of loop
>
> I would like to loop the multiple variables rather than put all the
> variables into a single variable with an array. I can not figure out how
> to
> do this.
>
> I have very little knowledge of PHP but am learning. Let me know if more
> information is needed.
//Untested code.
$connection = @mysql_connect('localhost', 'USERNAME', 'PASSWORD') or
trigger_error(@mysql_error() . " connecting to mysql", E_USER_ERROR);
@mysql_select_db('DATABASENAME', $connection) or
trigger_error(@mysql_error($connection) . " selecting database",
E_USER_ERROR);
$query = "select name, description from whatever order by name";
$people = @mysql_query($query, $connection) or
trigger_error(@mysql_error($connection) . " $query", E_USER_ERROR);
while (list($name, $description) = @mysql_fetch_row($people)){
echo "<P>$name<BR>\n$description</P>\n";
}
--
Like Music?
http://l-i-e.com/artists.htm