Humanitarian Open Source Software Development: Student P MySQL Source Code

classlist.php

CPSC225 Class List

<?php

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

/** 	* This function creates the connection to the specified database. *	* @author Turner Hayes * @param string $db *	*/

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

if (!(@ mysql_select_db($db, $connection))) showerror; }

db_connect('sahana');

$sql = "SELECT DISTINCT			'm'.'name' AS 'Name',			'm'.'email' AS 'Email',			'm'.'role' AS 'Role',			't'.'team_name' AS 'Team Name',			's'.'name' AS 'School'			's'.'city' AS 'City',			's'.'state' AS 'State'		FROM			'members' AS 'm',			'teams' AS 't',			'schools' AS 's'		WHERE			't'.'team_id' = 'm'.'team_id' AND			's'.'school_id' = 'm'.'school_id'"; if (!($result = @ mysql_query ($sql, $connection))) { showerror; }

print "