Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 8th, 2013  |  syntax: None  |  size: 1.48 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. include('connectdb.php');
  3. $sql = "SELECT * FROM tblmovies ORDER BY _id";
  4. $result = mysql_query($sql);    
  5. if($result === FALSE) {
  6.  die(mysql_error()); // TODO: better error handling
  7. }
  8. $set = array();
  9. while($row1 = mysql_fetch_assoc($result)) {
  10.     $set[] = $row1;
  11. }
  12. echo json_encode($set);
  13.        
  14. [{"_id":"3","movie_name":"Despicable Me 2","movie_cinema_number":"CINEMA     1","movie_length":"1hr. 40mins.","movie_type":"GP","movie_schedules":"12:10 PM | 02:25 PM | 04:40 PM","movie_image_url":"http://i39.tinypic.com/szizo4.jpg"},{"_id":"4","movie_name":"White House Down","movie_cinema_number":"CINEMA 2","movie_length":"2 hrs. 10 mins.","movie_type":"PG-13","movie_schedules":"12:30 PM | 03:20 PM | 06:10 PM","movie_image_url":"http://i39.tinypic.com/vp9n9j.jpg"},{"_id":"5","movie_name":"My Lady Boss","movie_cinema_number":"CINEMA 3","movie_length":"1hr. 50 mins.","movie_type":"PG-13","movie_schedules":"01:00 PM | 03:30 PM | 06:00 PM","movie_image_url":"http://i44.tinypic.com/2qlv08z.jpg"},{"_id":"6","movie_name":"Four Sisters And A Wedding","movie_cinema_number":"CINEMA 4","movie_length":"2 hrs. 5 mins. ","movie_type":"PG-13","movie_schedules":"12:30 PM | 03:10 PM | 05:50 PM","movie_image_url":"http://i44.tinypic.com/9iv0d1.jpg"}]
  15.        
  16. $array = array("title" => "TEST", "username" => "test"); // Creating a array
  17. echo json_encode($array); // Printing json
  18.        
  19. $json = file_get_contents('http://www.example.com/test/films.json'); // Your url
  20. $array = json_decode($json); // Your first array its here!
clone this paste RAW Paste Data