Sunday, 15 May 2011

how to get image url from database in php? -


I have problem in showing image url link on my showdb.php

My current DB record:

| _id _____ | ____ name _____ | _image |
____ 1 _____ | __bane ____ | Done Jp | | | | ____ 2 _____ | __aple ______ | Apple. JPG |

What do I want to do to know how this record is displayed in php after banana.jpg or image column below is www.myhost.com/image/banana.jpg?

What I find right now:
{"posts": [{"name": "banana", "image": banana.jpg}, // this {"name "From:" apple "," image ": apple.jpg} // this from}}


What do I need:

 < Code> {"post": [["name": "banana", & lt; Br> "Image": www.myhost.com/image/banana.jpg}, // this {"name": "apple", & lt; Br> "Image": www.myhost.com/image/apple.jpg} // be it}}  



And it's mine To show the current code your DB record:

  if ($ rows) {$ response ["success"] = 1; $ Response ["message"] = "post available!"; $ Response ["post"] = array (); Forex Currency ($ line as line $) {$ post = array (); $ Post ["name"] = $ line ["name"]; $ Post ["image"] = $ line ["image"]; // Update our repsonse JSON data array_push ($ response ["post"], $ post); } // resonant JSON response echo json_encode ($ response); } And {$ response ["success"] = 0; $ Response ["message"] = "no post is available!"; Die (json_encode ($ response)); }  

Is that code correct to change?
or if there is a link to do so, I am very happy :))

For your reply, thanks :))) * And sorry if my english is bad :)

============================================== ================================================== Resolve by: ============================= .yourhost.com / folder / '(dot) $ line ["image"]; = & Gt; 'Www.yourhost.com' $ line ["image"].

But, this will change to / in \ / : 'www.yourhost.com/file/ / file Add .jpg

JSON_UNESCAPED_SLASHES , for example:

  $ url = 'http://www.example.com/ '; Echo json_encode ($ url), "\ n"; Echo json_encode ($ url, JSON_UNESCAPED_SLASHES), "\ n";  

Happy coding people! :))

just attached to www.myhost.com/image/ Do your image entry in the post array

  if ($ rows) {$ response ["success"] = 1; $ Response ["message"] = "post available!"; $ Response ["post"] = array (); Forex Currency ($ line as line $) {$ post = array (); $ Post ["name"] = $ line ["name"]; $ Post ["image"] = 'www.myhost.com/image/'$$[[image "]; // Insert here // Update our representative JSON data array_push ($ response ["post"], $ post); } // resonant JSON response echo json_encode ($ response); } And {$ response ["success"] = 0; $ Response ["message"] = "no post is available!"; Die (json_encode ($ response)); }  

No comments:

Post a Comment