Reference columns by name
<html>
<body>
<?php
$host="mysql153.secureserver.net";
$uname="java2s";
$pass="password";
$database="java2s";
$tablename="Employee";
$connection= mysql_connect ($host, $uname, $pass) or die ("Database connection failed! <br>");
$result=mysql_select_db ($database) or die ("Database could not be selected");
$query = "SELECT * from ". $tablename;
$result = mysql_query ($query);
echo "<table>";
echo " <tr>";
echo " <td> <center><b>ID</b></center></td>";
echo " <td> <center><b>First Name</b></center></td>";
echo " <td> <center><b>Last Name</b></center></td>";
echo " </tr>";
while ($row=mysql_fetch_array ($result))
{
echo " <tr>\n";
echo " <td>". $row["ID"]. "</td>";
echo " <td>". $row["FirstName"]. "</td>";
echo " <td>". $row["LastName"]. "/td>";
echo " </tr>";
}
echo "</table>";
?>
</body>
</html>
Related examples in the same category