mysql - Result set order changing in php -


i have result set , need displayed on screen.but problem while displaying each row of result set using echo command order getting changed.can why happening , provide me way overcome it.here actual , printed outputs.

actual result set:

jaike-ilene-wacki-mazie-regle-sbj-kmmu   lvz-harty-mugzy-stw  mazie-sixie-sbj-kmmu   pxt-louie-gatby-razer-buzie-jaike-ilene-wacki-mazie   swann-gatby-razer-buzie-jaike-ilene-wacki-mazie   

output:

 jaike-sbj-ilene-kmmu-wacki-mazie-regle  mugzy-stw-lvz-harty  sbj-kmmu-mazie-sixie  ilene-gatby-wacki-razer-mazie-buzie-pxt-jaike-louie  wacki-razer-mazie-buzie-jaike-swann-ilene-gatby   

here code

$sql3="select group_concat(l.fix_ident separator '-') fix_seq,l.airport_ident,x.star_ident,x.transition_ident,                  x.fix_ident corept.std_star_leg l                  join                     (select distinct c.airport_ident,c.star_ident,c.transition_ident,c.fix_ident                      corept.std_star_leg c                      inner join                           (select star_ident,transition_ident,max(sequence_num) seq,route_type                            corept.std_star_leg                            data_supplier='j'                            , airport_ident='kmmu'                            group star_ident,                            transition_ident)b on c.sequence_num=b.seq                            , c.star_ident=b.star_ident , c.transition_ident=b.transition_ident                            left join                                (select name,trans                                 skyplan_deploy.deploy_stars                                 apt='kmmu'                                 , name!=trans) d                                 on d.name=c.star_ident                                 , d.trans=c.fix_ident                                 c.data_supplier='j'                                 , c.airport_ident='kmmu' , d.name null)x                                 l.airport_ident='kmmu' , l.transition_ident=x.transition_ident                                 , l.star_ident=x.star_ident , l.data_supplier='j'                                 group x.star_ident,x.transition_ident                                 order l.star_ident,x.transition_ident,l.sequence_num";   $res3=mysqli_query($mysqli,$sql3);   if($res3)   {     while($newarray3=mysqli_fetch_array($res3,mysqli_assoc))     {     $apt=$newarray3['airport_ident'];     $star_ident=$newarray3['star_ident'];     $trans_ident=$newarray3['transition_ident'];     $fix_ident=$newarray3['fix_ident'];     $fix_seq=$newarray3['fix_seq'];     echo $apt.",".$star_ident.",".$trans_ident.",".$fix_ident.",corept,".$fix_seq;     echo "<br>";     }   }  else  {    printf("error:%s\n",mysqli_error($mysqli));  } 

your query looks overly complex. appears finding groupwise maximum std_star_leg records sequence_num (grouped on start_ident , transition_ident), excluding there matching non-self-referencing deploy_star, returning results grouped again matching fix_ident values concatenated string?

if so, following simplified query ought achieve same outcome:

select   group_concat(fix_ident separator '-') fix_seq,          airport_ident,          star_ident,          transition_ident     corept.std_star_leg l natural join (            select   star_ident, transition_ident,                     data_supplier, airport_ident,                     max(sequence_num) sequence_num                corept.std_star_leg               data_supplier = 'j'                 , airport_ident = 'kmmu'            group star_ident, transition_ident          ) b    not exists (            select null              skyplan_deploy.deploy_stars d             d.name != d.trans               , d.name  = l.star_ident               , d.trans = l.fix_ident               , d.apt   = l.airport_ident          ) group star_ident, transition_ident 

note whereas selecting x.fix_ident in outermost select list, have omitted such column because value indeterminately selected server amongst in fix_seq.

now, problem (which appears related order in fix_ident values appear within group_concat() string fix_seq—although it's terribly hard appreciate question), perhaps want use order by parameter group_concat() function? example:

select group_concat(fix_ident separator '-' order ...) fix_seq 

however, not clear me ordering require (the order by clause in original query entirely redundant).


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -