Re: Little Problem with my Guestbook

From: Date: Wed, 14 Sep 2005 06:44:46 +0000
Subject: Re: Little Problem with my Guestbook
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-222350@lists.php.net to get a copy of this message
Florian Paucke wrote: > Hi. > > I'm new to PHP. > > I need some help from you, because, I'm creating a > guestbook. But I have a little problem. > > I have a table, where the different My-SQL-Entries > are read out. > But now I get only one Entry, but not more. > > How can do it, that the table read out 4 times, when > 4 entries are in the database? > > And the cursor from the database are jumping to > the next entry. > > Sorry for my bad english. :) Assuming you are using a SELECT statement that returns more than one row, you need to loop through the rows that are returned by your query. Have a look at the examples for mysql_fetch_array in the php docs at php.net/mysql_fetch_array The examples show the entire process from the SELECT statement through to printing the results with printf. You may find printf a bit daunting; echo might be easier for a beginner unless you are used to C. To use echo, in example 3 replace printf("ID: %s Name: %s", $row["id"], $row["name"]); with echo "ID: {$row["id"]} Name: {$row["name"]}"; Cheers -- David Robley I Never Knew A Cat Who Suffered From Insomnia.

« previous php.general (#222350) next »