json and multi-dimensional array

Thread Solved

Join Date: Oct 2009
Posts: 25
Reputation: garcon1986 is an unknown quantity at this point 
Solved Threads: 0
garcon1986 garcon1986 is offline Offline
Light Poster

json and multi-dimensional array

 
0
  #1
20 Days Ago
Hello everyone,

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

Here is my code:

  1. while($row = mysql_fetch_assoc($result)){
  2. echo json_encode($row);
  3. }

The result is:

  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:

  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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC