Location: PHPKode > projects > Simple Comments > comments/index.php
<? require("header.php"); ?>
<p align="center">
<a href="addcomment.php">Add Comment</a><br><br><hr>
<?
require_once( 'config.php' );
mysql_connect($dbaddress,$dbuser,$dbpass);
@mysql_select_db($dbname) or die( "Unable to select database");
$query="SELECT * FROM comments";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$userip=getenv('REMOTE_ADDR');

$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");
$ip=mysql_result($result,$i,"ip");
$name=mysql_result($result,$i,"name");
$timedate=mysql_result($result,$i,"timedate");
$message=mysql_result($result,$i,"message");
?>
<p align="center">
<?
echo "<b>Name: $name</b><br>Date/Time Posted: $timedate<br><br>Message:<br>$message<br>";
if ($ip==$userip) {
?>
<br><a href="deletecomment.php?id=<? echo $id; ?>">Delete Comment</a><br>
<?
}
echo "<hr>";
$i++;
}



?>
<p align="center">
<a href="addcomment.php">Add Comment</a><br><br><br>
<h5 align="center">
<a href="admin">Admin</a>
Return current item: Simple Comments