How to fetch and display values from database (MySQL) using php

<?php
  $con = mysqli_connect("localhost", "username","pswd","dbname");
    // Check connection
  if (mysqli_connect_errno())
  {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  else
  {
    $query ="SELECT * FROM employee_table ORDER BY ID DESC";  
    $result = mysqli_query($con, $query); 
    while($row = mysqli_fetch_array($result))
   { 
     echo "<table><tr><th>firstname</th><th>lastname</th><th>gender</th></tr><tr><td>".$row['frame']."</td>".$row["lname"]."<td>".$row['gender']."</td></tr></table>";  
  }
}
?>

Published by deeps blog

Programmer

Leave a comment

Design a site like this with WordPress.com
Get started