Advertisement
Guest User

Json analise

a guest
Sep 12th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2.  
  3. header('Content-disposition: attachment; filename=tutorial.json');
  4. header('Content-type: application/json');
  5.  
  6. $host="db4free.net"; //replace with database hostname
  7. $username="xxxx"; //replace with database username
  8. $password="xxxxx"; //replace with database password
  9. $db_name="xxxxx"; //replace with database name
  10.  
  11. $con=mysql_connect("$host", "$username", "$password")or die("Nao foi possivel Conectar");
  12. mysql_select_db("$db_name")or die("Banco de dados Indisponivel");
  13.  
  14. $return_arr = array();
  15.  
  16. $fetch = mysql_query("SELECT * FROM anuncios ORDER BY data");
  17.  
  18. while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
  19. $row_array['country'] = $row['titulo'];
  20. $row_array['code'] = $row['id'];
  21.  
  22. array_push($return_arr,$row_array);
  23. }
  24. mysql_close($con);
  25. echo json_encode($return_arr);
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement