| 
	
 | 
 Posted by David Robley on 09/14/05 09:44 
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.
 
  
Navigation:
[Reply to this message] 
 |