Humanitarian Open Source Software Development: Student J MySQL Source Code

[article] [edit page] [discussion] [history]

From Humanitarian-FOSS Project Development Site

<!DOCTYPE HTML PUBLIC
                 "-//W3C//DTD HTML 4.01 Transitional//EN"
                 "http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>CPSC 225 Members List</title>
</head>

<body>
<h1>CPSC 225 Members List</h1>
<table>
<tr><th>Email</th><th>Name</th><th>School</th><th>Role</th><th>City</th><th>State</th><th>Team Name</th></tr>
<?php 
	/**
	* Members list, phpDocumentor Quickstart
	*
	*@author Student J
	*@version 1.0
	**package members list
	*/
	
	/**
	*
	*Showerror function
	*@return string
	*
	*/
   function showerror()
   {
      die("Error " . mysql_errno() . " : " . mysql_error());
   }

   /*
   *If statement that returns a string of the error received when connecting to a MySQL DBMS
   *@return string
   */
   if (!($connection = @ mysql_connect([server],[username],[password]))) //actual data removed --Antonio
      die("Could not connect");

   /**
   * Selects the mcanning database
   *	@return string
   */ 
   if (!(@ mysql_select_db("mcanning", $connection)))
      showerror();

   /**
   *Selects the proper attributes to display
   *
   */
   if (!($result = @ mysql_query ("SELECT Members.Email, Members.Name, Members.School, Members.Role, Schools.City, Schools.State, Teams.Team_Name FROM Members, Schools, Teams WHERE Members.School = Schools.School_Name and Members.Team = Teams.Team_Number")))
      showerror();

   /**
   *while there are still rows in the Database, this returns the String attribute
   *@return string
   */
   while ($row = @ mysql_fetch_array($result, MYSQL_NUM))
   {
     // (5) Print out each element in $row, that is, print the values of
     // the attributes
     echo(" <tr>");
      foreach ($row as $attribute)
      
         print "<td> {$attribute} </td>";

      // Print a carriage return to neaten the output
      print "</tr>\n";
      
   }
?>
</table>
</body>
</html>

Personal tools