Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-disposition: attachment; filename=tutorial.json');
- header('Content-type: application/json');
- $host="db4free.net"; //replace with database hostname
- $username="xxxx"; //replace with database username
- $password="xxxxx"; //replace with database password
- $db_name="xxxxx"; //replace with database name
- $con=mysql_connect("$host", "$username", "$password")or die("Nao foi possivel Conectar");
- mysql_select_db("$db_name")or die("Banco de dados Indisponivel");
- $return_arr = array();
- $fetch = mysql_query("SELECT * FROM anuncios ORDER BY data");
- while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
- $row_array['country'] = $row['titulo'];
- $row_array['code'] = $row['id'];
- array_push($return_arr,$row_array);
- }
- mysql_close($con);
- echo json_encode($return_arr);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement