Advertisement
khirulnizam

listing.php basic PHP DB connection and listing data

Jul 18th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2. // listing.php
  3. //to display from table
  4. //1. connect to database
  5. include "connection.php";
  6.  
  7. //2. provide sql command
  8. $sql="select EMPNO, FIRSTNAME,
  9.     LASTNAME, PHONENO
  10.     from employee";
  11. //3. run the sql command to db
  12. $qr=mysqli_query($db, $sql);
  13.  
  14. //4. fetch one record
  15. while($rekod=mysqli_fetch_array($qr)){
  16. //5. display record(s)
  17.     echo "<br>";
  18.     echo "Employee no ".$rekod['EMPNO'];
  19.     echo "Firstname ".$rekod['FIRSTNAME'];
  20.     echo "Lastname ".$rekod['LASTNAME'];
  21.     echo "Phone ".$rekod['PHONENO'];
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement