944,138 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2591
  • PHP RSS
Nov 3rd, 2009
0

json and multi-dimensional array

Expand Post »
Hello everyone,

I have a problem when i use json and array. And i need your help.

Here is my code:

PHP Syntax (Toggle Plain Text)
  1. while($row = mysql_fetch_assoc($result)){
  2. echo json_encode($row);
  3. }

The result is:

PHP Syntax (Toggle Plain Text)
  1. {"id":"1","title":"event1","start":"2009-11-10 14:18:15","end":"2009-11-03 14:38:22","allDay":"false","url":null}{"id":"2","title":"event2","start":"2009-11-09 15:41:20","end":"2009-11-10 16:41:25","allDay":"false","url":null}

But i want the result is like this:

PHP Syntax (Toggle Plain Text)
  1. [{"id":"1","title":"event1","start":"2009-11-10 14:18:15","end":"2009-11-03 14:38:22","allDay":"false","url":null},{"id":"2","title":"event2","start":"2009-11-09 15:41:20","end":"2009-11-10 16:41:25","allDay":"false","url":null}]

How can i accomplish this? Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
garcon1986 is offline Offline
27 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Making an Admin page
Next Thread in PHP Forum Timeline: Opening email client with pdf attached to it





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC