aquaballoon

PHP - mysqli

Oct 14th, 2014
285
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.        
  3.         // $conn =  new mysqli("localhost", "root", "abc123", "RamaBook");
  4.         $conn =  mysqli_connect("localhost", "root", "abc123", "RamaBook");
  5.        
  6.         $query = "select name, city from customers";
  7.        
  8.         //$result = mysqli_query($conn, $query);
  9.         $result = $conn -> query($query);
  10.        
  11.         //$num_results = mysqli_num_rows($result);
  12.         $num_results = $result -> num_rows;
  13.        
  14.         for($i=0; $i < $num_results; $i++) {
  15.            
  16.             //$row =  mysqli_fetch_object($result);
  17.             $row = $result -> fetch_object();
  18.            
  19.             echo $row->name .  " " . $row->city;
  20.             echo "<br>";
  21.         }        
  22.         ?>
Advertisement
Add Comment
Please, Sign In to add comment