Display Records From MySQL table


In order to display records from MySQL table create DisplayRecord.php file as shown below:

     

<html>
<head>
<Title> Display Record</title>
</head>
<body>
<table border="1" >
<tr>
<th>Customer Code</th>
<th>Customer Name</th>
<th>Customer City</th>
</tr>
<?php
// Establish Connection with Database
$con = mysql_connect ("localhost","root");
// Select Database
mysql_select_db("DBDEMO", $con);
// specify the query to execute
$sql = "select * from Customer_Master";
// execute query
$result = mysql_query ($sql,$con);
// Loop through each records
while ($row = mysql_fetch_array($result))
{
$Code=$row ['CustomerCode'];
$Name=$row ['CustomerName'];
$City=$row ['City'];
?>
<tr>
<td><?php echo $Code;?></td>
<td><?php echo $Name;?></td>
<td><?php echo $City;?></td>
</tr>
<?php
}
?>
<?php
// Close the connection
mysql_close ($con);
?>
</table>

Download Projects


Download Programs