Muhaiminur
6/4/2017 - 1:16 PM

connect database with php and retrieve data and show them in table

connect database with php and retrieve data and show them in table

<?php
$con=mysqli_connect("localhost","root","root","cv");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM studentinfo");

echo "<table border='1'>
<tr>
<th>LIST</th>
<th>NAME</th>
<th>ROLL</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td><a href='updateform.php'>" . $row['name'] . "</a></td>";
echo "<td>" . $row['role'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>