From: Ron Piggott <ron.php@actsministries.org>
Date: Mon, 14 Jul 2008 02:21:23 -0400
Message-Id: <1216016483.3125.4.camel@localhost.localdomain>
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