How to use select statement in MySQL through PHP
In this article I am going to explain about how to retrieves table data from MySQL.
PHP MySQL select statement
The select statements is used to retrieves data from one or more tables.
Syntax of select statement
SELECT columnName FROM tableName;
or
SELECT *(for hole table) FROm tableName; |
Example of select statement
<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");
while($row = mysql_fetch_array($result))
{
echo $row['Fname'] . " " . $row['LastName'] . " ". $row['Id'];
echo "<br />";
}
mysql_close($con);
?>
</body>
</html>
|
Output:

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