From: Ron Piggott <[EMAIL PROTECTED]>
Date: Mon, 14 Jul 2008 02:21:23 -0400
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" :

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

Cheers - Neil

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to