Welcome to the make php
This page was creatd by Dr. Ramsey. Some of the features are *extra* and are not required. However, this is a good demo of how the project *can* come together. You should leave a description of your progress, your group and your pages in your make.php. The hardest part of making these pages was being sure to show you just enough sample code that I felt all of you would eventually be able to code up your own database website.


In specific this page will do the following:

query($query); if(!$result) { echo "
bad query - couldn't drop all the tables
"; } else { echo "
tables dropped
"; } # ******************************************************* # HERE WE WILL CREATE STUDENTS $query="CREATE TABLE Students ( ID int NOT NULL AUTO_INCREMENT PRIMARY KEY, First varchar(255), Last varchar(255))"; $result = $link->query($query); if(!$result) { echo "
bad query - create students table
"; } else { echo "
students table created
"; } # ******************************************************* // insert into students a few rows $query = "INSERT INTO Students (First, Last) VALUES ('Doc','Ramsey')"; $result = $link->query($query); if(!$result) { echo "
bad query - insert doc ramsey into students
"; } else { echo "Inserted Doc Ramsey
"; } $query = "INSERT INTO Students (First, Last) VALUES ('Brian','Rabner')"; $result = $link->query($query); if(!$result) { echo "
bad query into Students Table
"; } else { echo "Inserted Brian Rabner into Students Table
"; } # ******************************************************* # HERE WE WILL CREATE CLASSES $query="CREATE TABLE Classes ( ID int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(255) NOT NULL, Dept varchar(255) NOT NULL, Number int NOT NULL, Sec int NOT NULL )"; $result = $link->query($query); if(!$result) { echo "
bad query - create classes table
"; } else { echo "
classes table created
"; } # ******************************************************* //insert a few rows into classes $query = "INSERT INTO Classes (Name, Dept, Number, Sec) VALUES ('Databases','CSI',360, 10)"; $result = $link->query($query); if(!$result) { echo "
bad query - insert into classes 360
"; } else { echo " inserted Databases into Classes Table
"; } $query = "INSERT INTO Classes (Name, Dept, Number, Sec) VALUES ('Theory of Comp','CSI',350, 10)"; $result = $link->query($query); if(!$result) { echo "
bad query - insert into classes 350
"; } else { echo " inserted Theory of Comp into Classes Table
"; } # ******************************************************* # HERE WE WILL CREATE ATTENDING $query="CREATE TABLE Attending ( Student_ID int NOT NULL, Class_ID int NOT NULL, PRIMARY KEY (Student_ID, Class_ID), FOREIGN KEY (Student_ID) REFERENCES Students(ID), FOREIGN KEY (Class_ID) REFERENCES Classes(ID) )"; $result = $link->query($query); if(!$result) { echo "
bad query - create attending table
"; } else { echo "
attending table created
"; } # ******************************************************* //insert a few rows into attneding $query = "INSERT INTO Attending VALUES (1,1)"; $result = $link->query($query); if(!$result) { echo "
bad query - insert into attending 1,1
"; } else { echo " inserted 1,1 attending Table
"; } $query = "INSERT INTO Attending VALUES (1,2)"; $result = $link->query($query); if(!$result) { echo "
bad query - insert into attending 1,2
"; } else { echo " inserted 1,2 attending Table
"; } $query = "INSERT INTO Attending VALUES (2,1)"; $result = $link->query($query); if(!$result) { echo "
bad query - insert into attending 2,1
"; } else { echo " inserted 2,1 attending Table
"; } $link->close(); } else { echo "

Unable to connect to the database"; } ?>