PHP Code:
/**
* Create the table in your MySQL database:
*
* CREATE TABLE guests (
* id int(10) NOT NULL auto_increment,
* name varchar(50) NOT NULL,
* message varchar(255) NOT NULL,
* date timestamp(14) NOT NULL,
* PRIMARY KEY (id)
* )
*
* Change the database login settings to your own
*
* The script is now ready to run
*/
// Change these to your own database settings $host = "localhost"; $user = "username"; $pass = "password"; $db = "database";
mysql_connect($host, $user, $pass) OR die ("Could not connect to the server."); mysql_select_db($db) OR die("Could not connect to the database.");
$name = stripslashes($_POST['txtName']); $message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
$query = "SELECT id, name, message, DATE_FORMAT(date, '%D %M, %Y @ %H:%i') as newdate FROM guests ORDER BY id DESC";
$result = mysql_query($query);
while ($row = mysql_fetch_object($result)) {
?>
echo $row->message; ?>
Posted by echo $row->name; ?> on echo $row->newdate; ?>
}
?>
Post a message
No comments:
Post a Comment