Humanitarian Open Source Software Development: Student M MySQL Source Code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">  Member List <?php

/** * Members -- HW Assignment #3 CPSC-225 * * This php document accesses a MySQL database that contains three tables (members, schools, and teams). Then, using join commands, all the required data is accessed and placed in one table using php * * * @author Student M * @version 1.0 * */

/** * Function showerror * * Should the program throw an error, this function kills the running program and outputs information that is relevant to the error * */

function showerror {     die("Error " . mysql_errno . " : " . mysql_error); }

// Connects to LocalHost if (!($connection = @ mysql_connect("localhost", root, ""))) die("Could not connect");

// Accesses "cpsc225" database if (!(@ mysql_select_db("cpsc225", $connection))) showerror;

// MySQL command to query all the relevent information from the database if (!($result = @ mysql_query ("SELECT name, email, members.school, state, role, team_name FROM members, schools, teams WHERE members.school = schools.school AND members.team_num = teams.team_num", $connection))) showerror;

// Prints out all the returned data from MySQL

print " Name  E-Mail  School  State  Role  Team Name  ";

while ($row = @ mysql_fetch_array($result, MYSQL_NUM)) {	print " ";

foreach ($row as $attribute) {        print " {$attribute} "; }

print " ";

} ?>