Advertisement
ikamal7

m6.php

Sep 6th, 2020
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. //MySQL Insert Data
  3. $host     = 'localhost';
  4. $user     = 'root';
  5. $password = 'root';
  6.  
  7. $db_name = 'basicDB_2';
  8. //students_2
  9.  
  10. $mysql_conn = mysqli_connect( $host, $user, $password, $db_name );
  11.  
  12. if ( !$mysql_conn ) {
  13.     die( "Connection Failed" . mysqli_connect_error() );
  14. }
  15.  
  16. $sql = "SELECT id, firstname, lastname, email FROM students_2 ORDER BY id";
  17.  
  18. $result = mysqli_query( $mysql_conn, $sql );
  19.  
  20. //print_r( $result );
  21.  
  22. $rows = mysqli_num_rows( $result );
  23.  
  24. if ( $rows > 0 ) {
  25.  
  26.     while ( $row = mysqli_fetch_assoc( $result ) ) {
  27.         echo "id=" . $row["id"] . " Name - " . $row["firstname"] . " " . $row["lastname"] . " - Email - " . $row["email"] . "<br>";
  28.     }
  29.  
  30. }
  31.  
  32. mysqli_close( $mysql_conn );
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement