PHP/MySQL Database/mysql fetch assoc
Reading in Data
mysql_connect("localhost", "phpuser", "password");
mysql_select_db("phpdb");
$result = mysql_query("SELECT * FROM usertable");
if ($result && mysql_num_rows($result)) {
$numrows = mysql_num_rows($result);
$rowcount = 1;
print "There are $numrows people in usertable:<br /><br />";
while ($row = mysql_fetch_assoc($result)) {
print "Row $rowcount<br />";
foreach($row as $var => $val) {
print "<B>$var</B>: $val<br />";
}
print "<br />";
++$rowcount;
}
}