Advertisement
colmulhall

Untitled

Apr 1st, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.     $username = 'a9517348_colm';
  3.     $password = 'parkdbpass7';
  4.     $database = 'a9517348_parkdb';
  5.     $host = 'mysql5.000webhost.com';
  6.  
  7.     //create connection to the database
  8.         $con = mysqli_connect($host, $username, $password, $database);
  9.  
  10.     mysqli_select_db($con, $database)or die("cannot select DB");
  11.  
  12.    
  13.     //return all event titles from the database ordered by date
  14.     $sql = "select id, title, location, date from event_list order by id desc";
  15.  
  16.         $result = mysqli_query($con, $sql);
  17.     $json = array();
  18.  
  19.     //get each row of data from the database
  20.     if(mysqli_num_rows($result))
  21.     {
  22.             while($row = mysqli_fetch_assoc($result))
  23.             {
  24.                 $json['event_list'][] = $row;
  25.             }
  26.             echo json_encode($json);
  27.     }
  28.     mysqli_close($con);
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement