Re: Little Problem with my Guestbook

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

 



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.

-- 
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