Please sign my guestbook :
<form action="guestbook2.php" method="post">
Name: <input type="text" name="guestname"><br>
your comment: <input type="text" name="comment"><br>
<input type="submit"><br>
</form>
<br>
<table border=1>
<tr>
<td>
<B>name</b>
</td>
<td>
<b>comment</b>
</td>
</tr>
<?
$link = mysql_connect("localhost", "", "")
or die ("Could not connect");
mysql_select_db ("guestbook")
or die ("Could not select database");
$query = "SELECT * FROM guestsign";
/* you migh want to add a "LIMIT 0,30" */
/* or maybe a "ORDER BY id DESC"*/
$result = mysql_query ($query) or die ("Query failed");
$signnum = mysql_num_rows($result);
for ($i=1 ; $i <= $signnum ; $i++){
$row_array = mysql_fetch_array($result);
?>
<tr>
<td>
<?= $row_array["name"] ?>
</td>
<td>
<?= $row_array["comment"] ?>
</td>
</tr>
<?
}
mysql_close($link);
?>
</table>
|