Retrieve Data From MySQL Using PHP Tutorial

Data are often fetched from MySQL tables by executing SQL SELECT statement through PHP function mysql_query. you’ve got several options to fetch data from MySQ

For retrieve data from MySQL the SELECT statement is employed we will retrieve data from specific column or all column of a table.

For retrieve selected column data from database the SQL query is

SELECT column1,column2 FROM table_name;

For retrieve all the column data from a table the SQL query is

SELECT * FROM table_name;
In this tutorial we retrieve the data from MySQL database
In this tutorial having 2 files for retrive data
database.php – To connecting database
retrieve.php – For retrive data from database
$dbname = "user_details";
   die('Could not Connect My Sql:' .mysql_error());
include_once 'database.php';
$result = mysqli_query($conn,"SELECT * FROM details");
<!DOCTYPE html>
 <title> Retrive data</title>
if (mysqli_num_rows($result) > 0) {
    <td>First Name</td>
    <td>Last Name</td>
    <td>Email id</td>
while($row = mysqli_fetch_array($result)) {
    <td><?php echo $row["firstname"]; ?></td>
    <td><?php echo $row["lastname"]; ?></td>
    <td><?php echo $row["city"]; ?></td>
    <td><?php echo $row["email"]; ?></td>
    echo "No result found";

2 thoughts on “Retrieve Data From MySQL Using PHP Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *