Advertisement
Guest User

Untitled

a guest
Mar 19th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $user = "root";
  4. $pass = "";
  5. $db = "college";
  6. $con = mysqli_connect($host,$user,$pass,$db);
  7. $query = "SELECT firstname, secondname, pic FROM student";
  8. $result = mysqli_query($con,$query);
  9. $response = array();
  10. While($row= mysqli_fetch_array($result))
  11. {
  12. array_push($response,array('fname'=>$row[0], 'sname'=>$row[1], 'pic'=>$row[2]));
  13. }
  14. mysqli_close($con);
  15. echo json_encode(array('server_response'=>$response));
  16. ?>
  17.  
  18. {"server_response":[{" fname":"john","sname":"mark","pic":"http://localhost/ServerSide/jm.jpg"}]}
  19.  
  20. {"server_response":[{" fname":"john","sname":"mark","pic":"http://localhost/ServerSide/jm.jpg"}]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement