I want to display mysql database data in table format using php. my code is not working. I have data in table and connection is also made. However only the column title gets displayed, and not the database data.
<html>
<body>
<table style="width:300px">
<tr> <td>Empno</td> <td>Ename</td> <td>address</td> <td>City</td> </tr>
<?php include("conn.php");
$res=mysql_query("select * from info");
$res=mysql_query($res);
$i=1;
while($row=mysql_fetch_array($res)) { ?>
<tr> <td><?php echo ($row['empno']);?></td>
<td><?php echo ($row['ename']);?></td>
<td><?php echo ($row['address']);?></td>
<td><?php echo ($row['city']);?></td> </tr>
<?php $i++; } ?> </table>
</body>
</html>
From your code you are executing two time query :
$res=mysql_query("select * from info");
$res=mysql_query($res); // <------ Remove this code
Also what is your file name extension ? It should be .php
as you have tag html in your question. If it is in .html
change it to .php
On side note don't use mysql_* function since it deprecated see more here
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments