PHP/MySQL Web Development Using Dreamweaver

Defining MySQL tables with phpMyAdmin

MySQL is a free relational database system that is popularly used with PHP programs. For this class we will be using OIT's Webscript LAMP server. LAMP is a shorthand way of describing the server architecture. It means Linux, Apache, MySQL and PHP.

Note: All of the exercises in this guide contain demos for you to watch. To see them you will need to have the Macromedia Flash Player installed on your computer. In all the demos wherever you see the NetID "daveh" typed, substitute your own NetID.

Exercise 1

For our work with MySQL today we will be using a utility on Webscript called phpMyAdmin. Follow the link in the preceding sentence and log in to phpMyAdmin with your NetID and the password you used when you defined your account on the Instructional MySQL facility.

  1. As our first step we are going to create a new table in our database, "dwphpclass_lunch," that will allow us to keep track of the types of lunches we will offer to our conference attendees. Please also enter at least one sample record in your new table by using the "Insert" function of phpMyAdmin. Watch "exercise 1 demo part 1" to see how. (time 3:15)
  2. For the record, here are the fields in our new table dwphpclass_lunch:
    • id, integer, unsigned, auto_number, primary key field
    • name, varchar(20)
    • description, varchar(255)
    • price, float
  3. Download the file "dwphpclass_users.txt" to your desktop by right-clicking the preceding link and choosing the "Save Link As" or "Save Target As" option. This file contains a definition of a MySQL table needed for this class. Rather than having you type in all the needed information to create this table, we have done most of the work for you already.
  4. Now run the SQL commands in the file you downloaded in the preceding. This will create a table called "dwphpclass_users" in your database. As a final step we will modify this table by adding an additional field. At the end of the table we add a field called "lunch." (Let's imagine this table is to be used to allow people to register for a conference, and you want to let them choose the kind of lunch they would prefer.) Watch "exercise 1 demo part 2" to see how. (time 1:10)

After completing the above steps on your own you should have two tables in your MySQL database called "dwphpclass_users" and "dwphpclass_lunches."

Take me to the next section...

Last updated: 02/21/2006 8:00 AM
©2006. The Trustees of Princeton University.