


























# quick check FLUSH PRIVILEGES; DROP DATABASE IF EXISTS sj_pm; CREATE DATABASE sj_pm; GRANT ALL ON sj_pm.* TO stephanj@localhost IDENTIFIED BY 'letmein'; GRANT ALL ON sj_pm.* TO stephanj@'%' IDENTIFIED BY 'letmein'; |




| DROP
TABLE IF EXISTS school; CREATE TABLE school ( school_id smallint(3) NOT NULL AUTO_INCREMENT PRIMARY KEY, school_name varchar(20) NOT NULL )TYPE=InnoDB; #*** delete data from tables if exists DELETE FROM school; INSERT INTO school VALUES(1,'Wantirna'); INSERT INTO school VALUES(2,'Bayswater'); INSERT INTO school VALUES(3,'Scoresby'); INSERT INTO school VALUES(4,'Vermont'); INSERT INTO school VALUES(5,'Boronia'); |



| <?php //connects to database for gym program $db_host = "192.168.1.10"; // $db_host = "localhost"; $db_user = "stephanj"; $db_password = "letmein"; $db_name = "sj_gym"; $connection = @mysql_connect($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection) or die("Could not open database"); ?> |

| <html> <?php> require_once("connect.php"); ?> <head> <title>Gymnastics Program - 2005</title> </head> <body> <div id="topContent"> <h1>School Gymnastics Program</h1> <form action="studentresults.php" method="get" name="Student" target="mainFrame"> <fieldset> <legend>Select a school to view its students</legend> <label>School: </label> <select class="text"name="schoolselect" > <?php //Query database to find school names for drop down box $query = "SELECT * FROM school"; $result = mysql_query($query, $connection); //error report if(!$result) die("The query has failed with the following error : ".mysql_error($connection)); //loop through school names for($i=0; $i < mysql_num_rows($result); $i++) { //store school name in variable $schoolname = mysql_result($result, $i, "school_name"); //store school number in variable $schoolnumber = mysql_result($result, $i, "school_id"); //display html print "<option value='" .$schoolnumber."'>" .$schoolname. "</option>"; } //close connection mysql_free_result($result); mysql_close($connection); ?> </select><br /> </fieldset> </form> </div> </body> </html> |













