Select data from MySQL with HTML table through PHP

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

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




$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'>






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>";







You may also want to read these related articles :

Ask Your Question 

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

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.