php - Combine JSON array into single value -
I am trying to insert several JS key key values so that I can return only one value with all the data. For example, in my code, I want to add address 1, address2, address 3 to address Is it possible. I have tried several ways to experiment. = But anything seems to work. Gratefulness will be appreciated on any head. Thanks
$ query = "Select-from company_com"; = 0 to $; $ From = 30; $ Query = "LIMIT". $ From ",". $ To; $ Result = mysql_query ($ query) or die ("SQL Error 1:". Mysql_error ()); {$ Line = mysql_fetch_array ($ result, MYSQL_ASSOC)) {$ clients [] = array ('address1' => gt; $ line ['address1_com'], 'address2' = & gt; $ line ['address2_com '],' Address3 '= & gt; $ row [' address3_com ']); } Echo json_encode ($ clients);
You can type this very well .. < Pre> $ client = array (); $ I = =; $ Result = mysql_query ($ query) or die ("SQL Error 1:". Mysql_error ()); While ($ line = mysql_fetch_array ($ result, MYSQL_ASSOC)) {$ customers [$ i] ['address1'] = $ line ['address1_com']; $ Client [$ i] ['address2'] = $ line ['address2_com']; $ Client [$ i] ['address3'] = $ line ['address3_com']; $ I ++; } Echo json_encode ($ clients); Changes made: - moved out of
$ client array announcement while < / Li> - One flag
$ i = 0; is set out of . - The
$ client array is made 2-dimensional, as you can see that the $ i key has been passed as a key. - Finally,
$ i has increased.
edit: & lt; Php $ customers = array (); $ I = =; $ Result = mysql_query ($ query) or die ("SQL Error 1:". Mysql_error ()); While ($ line = mysql_fetch_array ($ result, MYSQL_ASSOC)) {$ customers [$ i] ['address'] = $ line ['address1_com'] "". $ Line ['address2_com'] "". $ Line ['address3_com']; $ I ++; } Echo json_encode ($ clients);
Comments
Post a Comment