RE : Subject: Formatting output with json_encode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




From: Ron Piggott <ron.php@xxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jul 2008 02:21:23 -0400
Message-Id: <1216016483.3125.4.camel@xxxxxxxxxxxxxxxxxxxxx>
Subject: Formatting output with json_encode

I am using json_encode to output the results of a mySQL query which is
part of a jquery & ajax.

$result = json_encode($array);
echo $result;

The output on my screen is:

{0:"John 14:27","verse_reference":"John 14:27"}

How do I format json_encode output?  I would like

John 14:27

to be what is displayed.


JSON is not intended to be "displayed", it's meant to be loaded by Javascript, typically with a javascript library such as jQuery, Ext or Prototype. The example on this page (happens to be .NET) shows how to make a POST request to the web server URL, retrieve the JSON encoded data, and display it in a DIV in a web page :

"Finally, the jQuery code to call the web service and appropriately handle its result" :
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Obviously, you'll now read the JSON, jQuery and HTML documentation to arrange that to your requirements Such as http://visualjquery.com/1.1.2.html and http://docs.jquery.com/Main_Page as well as the download site http://jquery.com/ : Be sure to pop back when you've read all about those with your DB specific questions ;-)

HTH
Cheers - Neil



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux