Need a Website Or Web Application Or Any Help In Code , Contact Us: +91 9437911966 (Whatsapp), Note: Paid Service

Retrieve Data From MySQL Using PHP

For retrieve data from MySQL the SELECT statement is used. We can retrieve data from specific column or all column of a table.

To retrieve selected column data from database the SQL query is

SELECT column_name,column_name FROM table_name;

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

SELECT * FROM table_name;

In the below example we retrieve the data from MySQL database.

In this example we used 2 file for retrieve data


 die('Could not Connect My Sql:' .mysql_error());


include_once 'database.php';
$result = mysqli_query($conn,"SELECT * FROM myusers");
<!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["first_name"]; ?></td>
    <td><?php echo $row["last_name"]; ?></td>
    <td><?php echo $row["city_name"]; ?></td>
    <td><?php echo $row["email"]; ?></td>
    echo "No result found";


table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;

td, th {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;


tr:nth-child(even) {
    background-color: white;