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

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi