addressbook db

Alles, was MySQL betrifft, kann hier besprochen werden.

addressbook db

Postby wittmebaa » 18. December 2010 17:38

ON EDIT - found it. Had an s on the word result for the query call. Works now.


New here. Trying to work thru the xampp example.

I have created the db and can view it fine thru the xampp tools. When I execute the page to open/query/close the .php shows this...which is not quite right.

The table gets constructed correctly as I took the loops out and left the table and headings - they were fine. As soon as it hits the echo in the php, it gets ugly.

There must be something syntactically wrong, but I just cant see it.

Note: I am running from my local PC, not the internet yet.

Image of output:

.php source:
Code: Select all

// Connect and select a database

mysql_connect("localhost", "root", "");


// Run query

$results = mysql_query("SELECT  * FROM colleague");


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

   <title>Address Book</title>
   <meta http-equiv="content-type" content="text/html.charset=utf-8" />

   <h1> Address Book</h1>
  <table border="1" cellpadding="2" cellspacing="3"  summary="Table holds colleague contact information">
         <th>First Name</th>
         <th>Last Name</th>

         <th>Email Address</th>


   // Loop thru all the table rows
   while ($row = mysql_fetch_array($result))
      echo "<tr>";
      echo "<td>" . $row['id'] . "</td>";
      echo "<td>" . $row['firstname'] . "</td>";
      echo "<td>" . $row['lastname'] . "</td>";
      echo "<td>" . $row['telephone'] . "</td>";
      echo "<td>" . $row['email'] . "</td>";
      echo "</tr>";



Posts: 4
Joined: 04. December 2010 17:09

Return to MySQL

Who is online

Users browsing this forum: No registered users and 3 guests