Accessing SQL from the Web using Forms, PHP and MySQL

Updated 7-Jan-2006

Here are the free packages to install for a Web Database Interface

Tests

Case Study

The county administrator comes to your office and says that they want to stop putting real estate transactions in the paper.

Your job, if you decide to accept, is to put it on the net!!!

Extras

Access Race Results from the 2000-2007 Charlottesville 10 Miler. LIVE DEMO - updated April 2005

Access the Race Results and Real Estate Sales Demo using a PHP library with full source code called Query Maker. LIVE DEMO - updated April 2005

MySQL Control Center is a great GPL Multi-Platform Tool for Querying, Browsing and Changing MySQL databases:
Get it here.


Suggestions for a database data dictionary

Create a table with this structure:

+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| column_name | varchar(80)  | YES  |     | NULL    |       |
| table_name  | varchar(40)  | YES  |     | NULL    |       |
| type_name   | varchar(4)   | YES  |     | NULL    |       |
| value_name  | varchar(10)  | YES  |     | NULL    |       |
| label_name  | varchar(100) | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+

 create table datadict(
        column_name varchar(80),
        table_name varchar(40),
        type_name varchar(4),
        value_name  varchar(10),
        label_name  varchar(100));


Populate it with code values from all the tables in your database. Ex-

insert into datadict values( "glasses", "health", "Code", "*", "No Answer");
insert into datadict values( "glasses", "health", "Code", "0", "None");
insert into datadict values( "glasses", "health", "Code", "1", "Reading");
insert into datadict values( "glasses", "health", "Code", "2", "Distance");
insert into datadict values( "glasses", "health", "Code", "3", "Bifocals");
insert into datadict values( "glasses", "health", "Code", "4", "Variable Focus");

For the RACE Table example:

+-------------+------------+-----------+------------+------------+
| column_name | table_name | type_name | value_name | label_name |
+-------------+------------+-----------+------------+------------+
| sex         | race       | K         | M          | Male       |
| sex         | race       | K         | F          | Female     |
+-------------+------------+-----------+------------+------------+
2 rows in set (0.00 sec)

mysql> insert into datadict values( "sex", "race", "K", "X", "Middlesex");
Query OK, 1 row affected (0.00 sec)


When entering the data from a web form, you can even construct the select box in real time by getting the data out of the data dictionary with PHP.
Live Demo - Link to Working Source Code

Required Reading

mySQL Manual and PHP Manual available from
PHP home page
MySQL home page

This page is http://people.virginia.edu/~rtg2t/webdb/home.html