[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    [PHP-DB] RE : Subject: Formatting output with json_encode
From:       "Neil Smith [MVP, Digital media]" <php () comatose ! freeserve ! co ! uk>
Date:       2008-07-14 23:05:02
Message-ID: 4F.C6.16803.E3BDB784 () pb1 ! pair ! com
[Download RAW message or body]


>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



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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic