Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

Code for viewing all entries

<?php
//enter your host details in here
$hostname = "localhost";
//enter your username in here
$username = "myusername";
//enter your password in here
$password = "mypassword";
//this is the database name
$database = "guestbook";
//make a connection
$connection = mysql_connect($hostname , $username , $password)
or die ("Cannot make connection");
//select our database
$db = mysql_selectdb($database , $connection)
or die ("Cannot connect to the database");
//select all fields in the guestbook table
$sql_query = "SELECT * FROM guestbook";
//store the result of the query in $result
$result = mysql_query($sql_query)
or die ("cannot execute query");
//build a simple table to display results
echo ("<table>");
//display some headings
echo ("<tr><td>name</td><td>comment</td><td>email</td></tr>");
//loop through fields
while ($rows = mysql_fetch_row($result))
{
//display name(rows[1]) , email(rows[3]) and comments(rows[2])
echo ("<tr><td>$rows[1]</td><td>$rows[3]</td><td>$rows[2]</td></tr>");
}
echo ("</table>");
?>

back to building a guestbook