www.webdeveloper.com
Results 1 to 3 of 3

Thread: json encode data

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Location
    faisalabad, punjab, pakistan
    Posts
    241

    json encode data

    hi how can i generate the following code example from php/mysql result set?


    PHP Code:

        
    echo json_encode(array(
        
            array(
                
    'title' => "Event1",
                
    'start' => "2013-02-10"
            
    ),
            
            array(
                
    'title' => "Event2",
                
    'start' => "2013-02-20"
            
    )
        
        )); 

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    Load the result data into a 2-D array (details will depend on what DB extension you are using), then json_encode() that array.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2003
    Posts
    598
    Also remember that json_encode() is fairly new and may not be included in your php install...i've ran into this a few times before, in which case there are some other functions and classes available to handle the task.
    We do precision guesswork

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles