1. #1
    Sencha Premium Member neenhouse's Avatar
    Join Date
    Dec 2007
    Location
    Austin
    Posts
    168
    Vote Rating
    1
    neenhouse is on a distinguished road

      0  

    Default multiple return rows: json format

    multiple return rows: json format


    Hello everyone,

    could someone give me an example of an array of returned JSON data that is 2 or more rows?

    Also, anyone have suggestions for json encoding functions? I updated to PHP 5.2.5 and am using json_encode, but had to write a small function with it to get it returning 1 row of data...

  2. #2
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    here is an example of how i do it, which is about as simple as it gets (you could also pass 'success' and 'totalProperty' values if you wanted):
    PHP Code:
    $sql "select * from table";
    $result mysql_query($sql);
    if (
    $result && mysql_num_rows($result)) {
      while (
    $row mysql_fetch_object($result)) {
        
    $data[] = $row;
      }
      
    $json->data $data//jsonReader's 'root' property is 'data' in this case
    } else {
      
    $json->data = []; //jsonReader will error if it has an undefined 'root' property, so feed an empty array to it if no results
    }
    print 
    json_encode($json); 

  3. #3
    Sencha Premium Member neenhouse's Avatar
    Join Date
    Dec 2007
    Location
    Austin
    Posts
    168
    Vote Rating
    1
    neenhouse is on a distinguished road

      0  

    Default thanks

    thanks


    thanks devnull, appreciate the help!

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar