thieumao

json_encode nhanh

Feb 10th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. require_once '/var/www/9football.net/wp-config.php';
  3.  
  4. $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Can't connect this database");
  5. //mysql_select_db(DB_NAME, $conn);
  6.  
  7. //$result = mysql_query($sql);
  8.  
  9. $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
  10. if (!$link) {
  11.     die('Could not connect: ' . mysql_error());
  12. }
  13. #echo 'Connected successfully';
  14. mysql_select_db(DB_NAME);
  15.  
  16. $sql    = "SELECT * FROM xemlailivetv ORDER BY pid ASC LIMIT 1000";
  17. $result = mysql_query($sql);
  18. if (!$result) {
  19.     echo "DB Error, could not query the database\n";
  20.     echo 'MySQL Error: ' . mysql_error();
  21.     exit;
  22. }
  23.  
  24. $data = array();
  25. while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
  26.  
  27.     $data[]=$row;
  28.  
  29. }
  30. echo json_encode($data);
  31. mysql_close($link);
Advertisement
Add Comment
Please, Sign In to add comment