Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. +----+---------+
  2. | ID | File |
  3. +----+---------+
  4. | 01 | abc.jpg |
  5. | 02 | cde.mp3 |
  6. | 03 | efg.doc |
  7. +----+---------+
  8.  
  9. $sql = "SELECT id,file FROM `test’ ”;
  10. if($stmt=$conn->prepare($sql)){
  11. $stmt->execute();
  12. $stmt->bind_result($id, $file);
  13. $array= array();
  14. while ($stmt->fetch()) {
  15. $array[]= array('id' =>$id ,’path'=>'http:// abc.com/file/'.$file);
  16. }
  17. $json=json_encode($array,JSON_UNESCAPED_UNICODE);
  18. }
  19. print_r($json);
  20. }
  21. else {
  22. };
  23.  
  24. [{"id": "01", "path": "http:// abc.com/file/abc.jpg"},
  25. {"id": "02", "path": "http:// abc.com/file/cde.mp3"},
  26. {"id": "03", "path": "http:// abc.com/file/efg.doc"}]
  27.  
  28. res.json({"Error" : false, "Message" : "Success", "Users" : rows}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement