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:
http://i.imgur.com/mLXxV.jpg

.php source:
Code: Select all
<?php

// Connect and select a database

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

mysql_select_db("addressbook");

// Run query

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

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


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


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

         <th>Telephone</th>
         <th>Email Address</th>
      </tr>


<?php

   // 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>";
      }
   mysql_free_results($results);
   mysql_close();
?>

   </table>

   </body>

</html>
wittmebaa
 
Posts: 4
Joined: 04. December 2010 17:09

Return to MySQL

Who is online

Users browsing this forum: No registered users and 5 guests