PHP and MySQL Library Tutorial

General
Site Root
Database Home
Conect to MySQL
MySQL_Login.php
nav.php
dump.php

Clean Up resets the
database to contain
a few sensible
records.

Download Tutorial

Database
Create
Drop

Person Table
Create
Drop

Insert
Delete
Update
Search
Date-Search

Row Dump
Better View 
Table View 
Form View

Book Table
Create
Drop

Insert
Delete
Update
Search




Table View 
Form View

Loan Table
Create
Drop

Insert
Delete

Search




Table View

Documentation
Data Requirements
User Interface Design
Entity Relationship Diagrams
Data Flow Diagrams
Data Dictionary
Implementation Notes
Table Designs
Goals, Testing and Appraisal

Note - Create, Drop and Clean Up would be hidden on a real life system.
Contact - nbauers at samphire dot demon dot co dot uk
Copyright © - You may use and reproduce this material in a "not for profit" setting.

SELECT * FROM person ORDER BY last_name, first_name

The lines below give a better way to see the database contents.

1 Mr Fred Bloggs 1992-12-27
3 Mr John Doe 1982-05-09
2 Ms Mary Jane 1991-11-24

Code Listing : personSelect2.php

<?php
  require "../MySQL_Login.php";    // Contains host, username, password, and database
  $link = mysql_connect($host, $user, $password) or die(mysql_error());
  mysql_select_db ($database) or die(mysql_error());
  $sql    = "SELECT * FROM person ORDER BY last_name, first_name";
  $result = mysql_query($sql, $link) or die(mysql_error());
  mysql_close($link);
?>

<html>
<head>
<title>SELECT * FROM person;</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php
  include "nav.php";
  echo"<font size=\"+2\"><b><pre>$sql</pre></b></font>";
?>

<p>The lines below give a better way to see the database contents.</p>

<?php 
  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
  {
    echo $row['person_id']     . " ";
    echo $row['title']         . " ";
    echo $row['first_name']    . " ";
    echo $row['last_name']     . " ";
    echo $row['date_of_birth'] . "<br>";
  }

  include "dump.php";
  dump_page(basename($_SERVER[SCRIPT_FILENAME]));  // Display the code of this page
?>

</body>
</html>