Example of mysql php list

esse quam videri
Jump to: navigation, search
class ReadWriteWeb {

	var $hdb;

	function __construct()
	{
		mysql_connect('localhost');
		mysql_select_db('rhamilton');
	}

	function ReadWriteWeb()
	{
		$this->__construct();
	}

	function getStudents()
	{
		$student_array = array();
		$students = mysql_query('A select statement here');
		
		while($associated = mysql_fetch_assoc($students))
		{
			$student_array[] = $associated;
			//echo ' < p r e > ';
			//print_r($student_array);
			//echo '< / p r e > ';
		}
		
		return $student_array;
	}
}

?>
<h1>Students <em><a href="new_student.php">create student</a></h1>
<?php

$ourclass = new ReadWriteWeb();

$students = $ourclass->getStudents();

?>

<dl id="students">

<?php
		if($students[0]['active']==1) {
			$class = 'active';
		} else {
			$class = 'inactive';
		}

		echo '<dt class="'.$class.'"><a href="'.$students[0]['url'].'">'.$students[0]['name'].'</a></dt>';
		
		echo '<dd>'.$students[0]['bio'].'</dd>';
?>

</dl>