School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Class / Forums / mysql101 ![]() |
Week #2 Basic To-Do Assignment |
(#17 2003-08-15 13:22:44) Post Reply |
|
TDavid
|
Your Week #2 Basic TO-DO assignment should be posted here in this thread only. If you have specific questions about the week 2 course text then please also post them in this thread so that other students can learn from the information and we can collectively build a knowledge base.
Here is the details on what you need to do in this assignment: Construct the Tables as indicated in this week's lesson and post the working source code here. Go back to Week #1 to see how to do this if you have to. Study CREATE TABLE queries in the MySQL manual if neccessary as well. |
(#21 2003-08-20 19:03:31) Post Reply |
|
lizabit
|
I saved 3 files, one created the database and the first table. The other 2 files for each of the other tables. I am implementing them on my localhost so there is no link to post.
create the database and add 1 table <? //connect to MySQL server: $db = mysql_connect("localhost", "lgrace", "nicho6uz") or die("Could not connect:". mysql_error()); //create the database: $query_create_db = "CREATE DATABASE IF NOT EXISTS MySponsors"; //Implement db $result_create_db = mysql_query($query_create_db,$db) or die("Could not create database:". mysql_error()); print("Database Created"); //connect to db mysql_select_db("MySponsors", $db) or die("Could not connect to database:". mysql_error()); print("Connected to database"); //create table $query_create_table = "CREATE TABLE Website_Sponsor ( ws_w_id MEDIUMINT(8) NOT NULL, ws_s_id MEDIUMINT(8) NOT NULL, KEY (ws_w_id), KEY (ws_s_id) ) TYPE=MyISAM"; //execute table query $result_create_table = mysql_query($query_create_table,$db) or die("Could not create table:". mysql_error()); print("Table Created"); ?> make sponsors table <? //connect to MySQL server: $db = mysql_connect("localhost", "lgrace", "nicho6uz") or die("Could not connect:". mysql_error()); //connect to db mysql_select_db("MySponsors", $db) or die("Could not connect to database:". mysql_error()); print("Connected to database"); //this is a php variable which creates table $query_create_table = "CREATE TABLE sponsors ( s_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT, s_name VARCHAR(255) NOT NULL DEFAULT '', s_url VARCHAR(255) NOT NULL DEFAULT '', s_staturl VARCHAR(255) NOT NULL DEFAULT '', s_email VARCHAR(255) NOT NULL DEFAULT '', s_uname VARCHAR(255) NOT NULL DEFAULT '', s_pass VARCHAR(255) NOT NULL DEFAULT '', s_date DATE DEFAULT NULL, S_status ENUM ('Pending','Active','Inactive','Defunct') NOT NULL DEFAULT 'Pending', PRIMARY KEY (S_id) ) TYPE=MyISAM"; //execute table query $result_create_table = mysql_query($query_create_table,$db) or die("Could not create table:". mysql_error()); print("Table Created"); ?> and finally make websites table <? //connect to MySQL server: $db = mysql_connect("localhost", "lgrace", "nicho6uz") or die("Could not connect:". mysql_error()); //connect to db mysql_select_db("MySponsors", $db) or die("Could not connect to database:". mysql_error()); print("Connected to database"); //this is a php variable which creates table $query_create_table = "CREATE TABLE Websites ( w_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT, w_name VARCHAR(255) NOT NULL DEFAULT '', w_url VARCHAR(255) NOT NULL DEFAULT '', w_desc TEXT, w_status ENUM ('Pending','Active','Inactive','Defunct') NOT NULL DEFAULT 'Pending', PRIMARY KEY (w_id), FULLTEXT KEY w_search (w_name, w_url, w_desc) ) TYPE=MyISAM;"; //execute table query $result_create_table = mysql_query($query_create_table,$db) or die("Could not create table:". mysql_error()); print("Table Created Websites"); ?> OK? Regards Liz |
(#30 2003-09-02 23:32:22) Post Reply |
|
logspirit
|
Looks OK
logspirit |
(#44 2003-09-18 09:52:54) Post Reply |
|
Shrek
|
Here is My Week #2 Assignment
sql02.create.ws.php |
(#46 2003-09-23 21:49:34) Post Reply |
|
logspirit
|
Shrek, You're on Your way to developing this program and learning as You go!
logspirit |
(#55 2003-10-10 15:32:10) Post Reply |
|
Donnie
|
Here is basic week 2.
Worked on local host. No host to upload to. |
(#58 2003-10-14 20:08:17) Post Reply |
|
logspirit
|
looks OK
logspirit - author of this course |
|
View Previous Thread Print This Page |
School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store
Advertising
| Link To Us | Privacy
Copyright 2000-2002 Script School Productions / KMR
Enterprises
No part of this website may be reproduced, copied and/or distributed
in any medium
without express written permission