Upload
charla-mckenzie
View
216
Download
0
Embed Size (px)
Citation preview
Methods to create a table
• At your local server and/or remote server– Use MySQL Console and create it interactively– Use a batch SQL script
• Use HTML and PHP scripts with goals:– Let user interactively define the fields– Identical development environment on local and
remote servers
2
Establish an identical environment
• Create a user on local server with the same <username> and <password> as your own on remote server (cs346)
• Create a database called <username> • See create_user_student.txt
3
Your Music collection
• Suppose you want to create a database table my_music with 8 attributes (columns)
• id• format• title• fname of artist• lname of artist• rec_label• my_notes• date_acq
4
Interaction of 3 scripts
• 12-1show_createtable.html to prompt for – Name of table– Number of attributes (columns)– Then call 12-1show_fielddef.php
• 12-1do_show_fielddef.php– Display a form for user to specify field names,
types, and length• 12-1do_createtable.php– Do the actual create table
5
6
Before running the scripts, list the tables in the database student by running http://127.0.0.1/student/m11/11-3db_listtables.php
See the following slide
10
Check if the table my_music has been really created in the database studentby running http://127.0.0.1/student/m11/11-3db_listtables.php
Hmm! The message is not quite correct. Intention is to show that the table is being added to the database ‘student’.Correction: remove the quotes around “DB_NAME”. But at this point, I need to drop the table and create it again. Let us fix the script, upload it to cs346 latgerand test again.
12
Upload the m12 directory by Fillzilla to /var/www/students/student
Then check the tables in the user student
16
Note: The message is corrected to show that the table is being added to the database ‘student’.My correction: remove the quotes around “DB_NAME”