To make progress on Project 3 and to understand...
Remember that you must...
Use WinSCP to connect to our remote server.
Details about your specific server, userid and password were emailed to you. Here is the general information:
ftp.sienasellbacks.com
or ftp.breimer.net
userid@sienasellbacks.com
or userid@breimer.net
Be sure to replace userid
with your actual Siena userid; But, do not add @siena.edu
project3
folder from the previous lab.project3
folder download project3.zip and unzip.project3
folder, open drop_courses_table.php
drop_table.php
courses
table. You will modify the script, so that
you can specify which table to drop as a URL parameterrequire
function, add the following:$table_name = $_GET['table_name'];
$table_name
$sql = "DROP TABLE $table_name";
drop_table.php?table_name=ebreimer_courses
userid_courses
where userid
is your userid.project3
folder, open create_courses_table.php
table_name
and set it to userid_courses
where userid
is your userid.$table_name
sql
string to the following:"CREATE TABLE $table_name ( cid INT NOT NULL AUTO_INCREMENT, sub VARCHAR(4) NOT NULL COMMENT 'Subject Area', num VARCHAR(3) NOT NULL COMMENT 'Course Number', title VARCHAR(48) NULL COMMENT 'Course Title', descr TEXT NULL COMMENT 'Course Description', year INT(4) NULL COMMENT 'Year Taken', sem VARCHAR(6) NULL COMMENT 'Semester Taken', uid VARCHAR(10) NOT NULL COMMENT 'Userid', PRIMARY KEY (cid) )";
year
to INT(4)
which will internally display this integer value using 4 digits.project3
folder, create a new file called show_table_columns.php
table_name
and set it equal to a URL parameter with the same name, i.e., $_GET['table_name']
SHOW FULL COLUMNS FROM $table_name
and store the results in a variable called cols
out
for storing the output and set it to '<h1>Columns of '.$table_name.'</h1>';
while($col = $cols->fetch_assoc()) { }
foreach ($col as $key=>$value) { }
out
variable:$out .= '<li><b>'.$key.':</b> '.$value.'</li>';
out
variable to create an unordered:$out .= '<ol>';
$out .= '</ol>';
$table_name
as the page name and $out
as the page content.
show_table_columns.php?table_name=userid_courses
project3
folder, open insert_course.php
ebreimer_courses
with your useridnull
.
Remember null strings are interpreted as false
null
, i.e., if ($sub && $num && $uid)
make_form
function and then slicing them as the values of the input elements.value
attribute that will display a value inside of the text box.
For example, the following input element would have the value CSIS inserted:<input type="text" value="CSIS">
make_form
function so that it take 3 parameters ($sub, $num, $uid) and sliced each of them value attribute of the appropriate input elements, i.e.,value="'.$sub.'"
$output = make_form($sub, $num, $uid);
make_table
function, change the select query to "SELECT * FROM $table_name ORDER BY cid DESC"
make_form
function, define the following helper function:
/* ----------------------------------------------------------------------- Makes a form group from a given id, label and value ----------------------------------------------------------------------- */ function make_form_group($id, $label, $value) { return ' <div class="form-group"> <label for="'.$id.'">'.$label.'</label> <input type="text" class="form-control" id="'.$id.'" name="'.$id.'" value="'.$value.'"> </div> '; }
make_form
function as follows:INSERT INTO $table_name (sub, num, uid) VALUES ('$sub', '$num', '$uid')
),
we will generate the field names and values and simplify the query as follows: INSERT INTO $table_name ($fields) VALUES ($values)
valid
to false and break out of the loop.$fields
equals the string sub,num,title,descr,year,sem,uid
and $value
would be of the form 'CSIS', '120', ..., 'user1'
None. To get credit for lab you must work productively for the 2 hour period.
While it is OK to help other students with concepts and general trouble-shooting, you should not share code. It is expected that each individual project will be unique.