Select data from MySQL with HTML table through PHP

In this article I am going to explain about retrieves data from MySQL.
  • 1950

PHP MySQL select statement with HTML table

You can also use HTML table with Mysql database. Here I will display  the data in as HTML table.

Example of select statement with HTML table

<html>

<body>

<?php

$con = mysql_connect("localhost","gupta","sharad");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("Mcn_Solution", $con);

 

$result = mysql_query("SELECT * FROM Emp");

echo "<table border='1'>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>EmpId</th>

</tr>";

while($rowval = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $rowval['Fname'] . "</td>";

  echo "<td>" . $rowval['LastName'] . "</td>";

  echo "<td>" . $rowval['Id'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

mysql_close($con);

?>

</body>

</html>


Output:

Htmlselect.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.