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