hi,
i have a little problem. I have a kind of guestbook and i get the messages out of a mysql db. I want to count the number of rows in the db and after wards give each message saved in the db an number. (The first msg get a 1 the next one a 2 and so on)
I tried to solve the problem with the for statement, but when i echo the value of the varible which shoulb be counted up it always gives me the value which i type in at the first part of the statemant. Heres the Code:
<?php
$verbindung = mysql_connect ("xxx.xxx.xx", "xxxx", "xxxx")
or die ("Could not connect");
$sql = "SELECT name, email, homepage FROM guestbook";
$ergebnis = mysql_db_query("edesignz",$sql, $verbindung);
$num_rows = mysql_num_rows($ergebnis);
echo "<h1> $num_rows</h1>";
for ($i=0; $i <= $num_rows; $i++)
{
while (list($name, $email, $homepage) = mysql_fetch_row($ergebnis))
{
// Ausgabe der Tabellen und ihrer Inhalte
echo "
Name : $name <br>
e-mail: $email <br>
Homepage : $homepage <br>
Message ID : $i
";
}
}
mysql_close($verbindung);
?>
So how can i fix it ? has anyone an idea ?
thanks in advance
al