Humanitarian Open Source Software Development: Students N, O MySQL Source Code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">  CPSC 225 CLASS LIST by Team Average Joe <?php /**	 * Prints classmates information based on information in a MYSQL databse. * We used Joint Queries to display the data from mutliple tables. * @author Student N, Student O        * @version 1.0 *	 */	/**	 * ShowError is a default error function written in case errors occur * while connecting to the databse. * @access public * @return void */	  function showerror {	     die("Error " . mysql_errno . " : " . mysql_error); }

/**   * Open the databse connection. If there is an error instead of printing out possible information * that could expose your username and password, the default error is overwritten, instead dying * saying only "could not connect" */  if (!($connection = @ mysql_connect("localhost","root","")))//Open the database connection die("Could not connect");

if (!(@ mysql_select_db("cpsc225", $connection)))// (Selects the cpsc225 databse     showerror;

/**	 * Join queries are used match information from the three tables, members, schools, and teams. * The information is then tied together using "WHERE" statements. Finally the data is organized b	 * team for easier viewing. If mysql query fails showerror msg is shown. */  if (!($result = @ mysql_query (   		" SELECT DISTINCT members.name,members.email,members.school,   						   schools.schools_state,members.role,teams.team_name	       FROM members,teams,schools	       WHERE members.school=schools.schools_name AND	       		 members.team_num=teams.team_key	       ORDER BY teams.team_key", //order by team name   		$connection))) showerror; /**		 * HTML to create, and label the table. */  		echo " "; echo " "; echo " "; echo " "; echo "		    Member	    	 Email	    	 School</CENTER></B></TD>	   		 State</CENTER></B></TD>	         Role</CENTER></B></TD>	    	 Team Name</CENTER>	     	 </B></TD></TR></THEAD>"; while ($row = @ mysql_fetch_array($result, MYSQL_NUM)) {     foreach ($row as $attribute) //each sql value is put into an HTML table. {     	echo " "; print "{$attribute} "; echo " "; }	 echo " "; print "\n"; }

?>