Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="XXX"; //replace with database hostname
- $username="YYY"; //replace with database username
- $password="ZZZ"; //replace with database password
- $db_name="ZZZ"; //replace with database name
- $ageFrom = $_GET['ageSearchFrom'];
- $ageTo = $_GET['ageSearchTo'];
- $con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $sql = "SELECT * FROM users WHERE age BETWEEN '$ageFrom' AND '$ageTo'";
- $result = mysql_query($sql);
- $json = array();
- if(mysql_num_rows($result)){
- while($row=mysql_fetch_assoc($result)){
- $json['user'][]=$row;
- }
- }
- mysql_close($con);
- echo json_encode($json);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement