Easy PHP Guestbook Part 5 – Retrieving from the Database


Apple iTunes

In Part 5 of the Easy PHP Guestbook tutorial we will cover retrieving the inserted data from the database and displaying it in a browser.

Create a new file and call it viewguestbook.php, open this file and put the following code in it.

$entriesq = mysql_query(“select * from guestbookentries”);
while($entriesr = mysql_fetch_array($entriesq)){
     $name = $entriesr["name"];
     $date = $entriesr["date"];
     $website = $entriesr["website"];
     $entry = $entriesr["entry"];
     echo “<tr><td>Name:</td><td>” . $name . “</td></tr>”;
     echo “<tr><td>Date:</td><td>” . $date . “</td></tr>”;
     echo “<tr><td>Website:</td><td>” . $website . “</td></tr>”;
     echo “<tr><td>Entry:</td><td>” . $entry . “</td></tr>”;

After you’ve made a few entries using the form from part 3 combined with the added code from part 4, you should be able to run this script and it should display all the entries that were inserted. Hopefully this was helpful to some. In the next few days I will be posting a download that has all these files with all of the source code as well as creating an advanced guestbook that can be purchased.

Similar Posts:

VN:F [1.9.22_1171]
Rating: 1.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Easy PHP Guestbook Part 5 – Retrieving from the Database, 1.0 out of 10 based on 1 rating
Be Sociable, Share!

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!