I have just learned PHP just for one week. Here is a problem that I cannot find the answer from my reference books. “How do I select the data from MySQL database and display the results in a table?”
Thanks for your help!!
<?
$connection=mysql_connect("localhost", "root", "") or die("couldn't connect");
$db=mysql_select_db("questionnairedb", $connection) or die("couldn't connect to database!");
$sql="select ID, District from testdb order by ID";
$result=mysql_query($sql,$connection) or die("couldn't execute the query");
$hm="<table border=1>";
for ($i=0; $i<mysql_num_rows($result); $i++){
$hm.="<tr><td>$ID</td><td>$District</td></tr>";
}
$hm.="</table>";
?>
<html>
<body>
<?
echo "$hm";
?>
</body>
</html>
Winter