Klasik Source Code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">  CPSC 225: Member List  <?php /**	* Function showerror, displays a sql error. *	* This function simply takes any sql error that may have occured * and displayes an error on the php page calling the query. * 	* @access public * @return void */  function showerror {     die("Error " . mysql_errno . " : " . mysql_error); }
 * Sahana Memberlist
 * MySQL exercise designed to show mastery of the basics of the SQL database language.
 * Displays the list of the members of the Sahana project by joining the members,schoools and teams tables.
 * @author Todd Klasik
 * @version 1.0
 * @author Todd Klasik
 * @version 1.0

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

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

if (!($result = @ mysql_query ("SELECT fname,email,school,schools.state,role,teams.teamname FROM members,schools,teams 						WHERE members.teamnum = teams.teamnum AND members.school = schools.sname 						 GROUP BY email", $connection))) showerror;

printMemberList($result) ?> <?php /**	* Function printMemberList, prints the member list as a table. *	* This function takes a previously called result from the database and * prints out a table w/ the appropriate header information. cycles through the * result table and prints out the differnt values for each member. *	* @param array $table table of return results from a sql query. * @access public * @return void */	function printMemberList($table) { echo " "; echo " Member Email School State Role Team Name\n"; while ($row = @ mysql_fetch_array($table, MYSQL_NUM)) {			echo " "; foreach ($row as $attribute) echo " {$attribute}"; // Print a carriage return to neaten the output echo "\n"; }	} ?>