First we have to create database in phpmyadmin and then we have to create a table.
For example :
Database : yourdbname
Table : user
roll name email
1 arvind 1@email.com
2 ajay 2@email.com
3 alok 3@email.com
Here is the following code in php to fetch data from database and show it on output-
<?php
$con= mysql_connect((“hostname”, “username”, “password”) or die (mysql_error()));
$db= mysql_select_db(“yourdbname”, $con);
$sql= “SELECT * FROM user WHERE 1”;
$qry= mysql_query( $sql );
?>
<table>
<tr>
<td>Roll-No</td> <td> studentname </td> <td> Email</td>
</tr>
<?php
while ( $rs = mysql_fetch_array($qry))
{
?>
<tr>
<td> <?php echo $rs[roll];</td> <td> <?php echo $rs[name]; ?></td> <td> <?php echo $rs[email]; </td>
</tr>
<?php
}
?>
</table>