Tuesday, 15 May 2012

php - Associative array always returns only 4 result -


You want to create an associative array for the bottom of the High Query query:

  $ sql = select "s. *, di.dealsimage, ctm.city, l.location, ordered by group_concat (different cm.cuisine scr.cuisine_sequence_for_store) as Cui, group_concat (dISTINCT rtm.restaurant_type order) by srr.rest_type_sequence_for_store stores s.store_id joining s left places left to be as restauranttype include city_master ctm on s.city_id = ctm.city_id L s.location_id = l.location_id left store_cuisine_relation scr = scr.store_id left lamp Joining cuisine_master cm join in on the left scr.cuisine_id = cm.cuisine_id at Sarar join store_resttype_relation include RTM on s.store_id = srr.store_id Arkti.amk Restran_prop_mastr rtm.rest_type_id = srr. rest_type_id left left dcm.deal_cat_id = sdr.deal_cat_id upon by left di.`store_id` = s.store_id which include deals_image di at $ CONDITION1 s.is_active = 1 $ CONDITION2 group s.store_id = sdr.store_id deals_category_master DCM When joining store_dealcat_relation joining the SDR (S.store_id) come by s.store_id Country; "; // echo $ sql; exit; // echo $ sql; exit; $ Sqlex1 = mysqli_query ($ db, $ sql); $ Custom_count = @ mysqli_num_rows ($ sqlex1); // print 28 while ($ result1 = mysqli_fetch_assoc ($ sqlex1)) {$ dataArr = array_push_assoc ($ dataArr, 'store_id', $ result1 [ 'store_id']); $ Detaare = array_push_assoc ($ Detaar, 'store_name', $ result1 [ 'store_name']); $ Detaare = Array_push_assoc ($ Detaar, 'store_logo', $ result1 [ 'store_image_url']); $ Detaaarar = Aarar_pshu_sak ($ ​​Detaar "Sudon_imej, $ results [1 'deals Month']);} // echo count ($ Datair); exit; // echo $ kl; exit; // $ result = array_merge_recursive ($ gpsArr, $ dataArr); function array_push_asso Query ($ array, $ key, $ value) {$ array [$ key] [] = $ value; $ array return;}  

query returns 28 results, but when I < code> $ dataArr that count to the resonant / it says it is always wrong to print 4? how it can be achieved? thanks in advance

its function array_push_assoc () make creates an array with 4 key store_id , store_name, store_logo , and deals_image`, and each The key has 28 rows

Try it out:

  dataArr = array (); While ($ result1 = mysqli_fetch_assoc ($ sqlex1)) {$ dataArr [] = array ( 'store_id' = & gt; $ result1 [ 'store_id'], 'STORE_NAME' = & gt; $ result1 [ 'STORE_NAME'], ' store_logo '= & Gt; $ results [1' Store_image_url '],' Sudon_imej '= & gt; $ results [1' deals Month ']); }  

This will create an array with 28 associate arrays


No comments:

Post a Comment