Tato123 Posted January 13, 2014 Report Share Posted January 13, 2014 ?> </br> <table id="tabledlist" class="tablevar"> <td>Spilla</td> <td>Nome</td> <td>Piloti</td> </tr> <?php $query="SELECT * FROM vawards_awards f LEFT JOIN vawards_grants p ON p.grt_awdid = f.awd_id WHERE f.typ_id = '1'"; $list=DB::get_results($query); foreach ( $list as $ist) { ?> <tr> <th><img src="<?php echo $ist->awd_image ?>"</th> <th><div align="left"><?php echo $ist->awd_name ?> </div></th> <th><?php echo $ist->grt_pilotid ?></th> </tr> <?php } ?> </table> <br /> Hallo Guy, i have a little problem. When i use the echo function : <th><?php echo $ist->grt_pilotid ?></th> the system dublicate any row for each record. Is possible have a column with multiple value separated from ; or , Example: the quaery sort all awards in dbase splitted for category. I need for all award the pilots list. Category Airline Image Award - Description, And the pilots VAR901, VAR902, VAR 505 Now i see a row for pilots http://www.virtualir...x.php/allawards I need only one row for award and the column Piloti multiple value 1 Quote Link to comment Share on other sites More sharing options...
Tom Posted January 13, 2014 Report Share Posted January 13, 2014 You can use the MySQL GROUP_CONCAT function to create the list you're looking for along with some grouping. Don't know what the field names are so I'm just guessing: $query = "SELECT *, GROUP_CONCAT(grt_pilotid) as pilots_list FROM vawards_awards f LEFT JOIN vawards_grants p ON p.grt_awdid = f.awd_id WHERE f.typ_id = '1' GROUP BY f.awd_id"; (Not tested) Quote Link to comment Share on other sites More sharing options...
Tato123 Posted January 13, 2014 Author Report Share Posted January 13, 2014 Thanks Tom for you repley. I put the query $query = "SELECT *, GROUP_CONCAT(grt_pilotid) as pilots_list FROM vawards_awards f LEFT JOIN vawards_grants p ON p.grt_awdid = f.awd_id WHERE f.typ_id = '1' GROUP BY f.awd_id"; $list=DB::get_results($query); foreach ( $list as $ist) { ?> <tr> <th><img src="<?php echo $ist->awd_image ?>"</th> <th><div align="left"><?php echo $ist->awd_name ?> </div></th> <th><?php echo $ist->grt_pilotid ?></th> </tr> <?php } ?> </table> <br /> But i show only 1 grt_pilot id and not the all pilots. If you wont see here: http://www.virtualir...x.php/allawards Is correct no change the line <th><?php echo $ist->grt_pilotid ?></th> ??? I need to show in the same column all the pilots id for that award Quote Link to comment Share on other sites More sharing options...
Tato123 Posted January 13, 2014 Author Report Share Posted January 13, 2014 Solved !! Thanks TOM I change <th><?php echo $ist->grt_pilotid ?></th> in <th><?php echo $ist->pilots_list ?></th> and work !!! Regars Quote Link to comment Share on other sites More sharing options...
Tato123 Posted January 14, 2014 Author Report Share Posted January 14, 2014 I would add the suffix VAR pilot in front of the id. (VAR901) I can not use the code because the pilot is in another table. Second thing, I wish id pilot was seen in three digits. Now I show 1 instead of 001 I find this way but I do not know how to apply it to my query { # Make sure values ​​are Entered if (Config :: Get ('PILOTID_LENGTH') =='') Config :: Set ('PILOTID_LENGTH', 4); if (Config :: Get ('PILOTID_OFFSET') =='') Config :: Set ('PILOTID_OFFSET', 0); $ pilotid pilotid + = $ Config :: Get ('PILOTID_OFFSET'); return $ code. str_pad ($ pilotid, Config :: Get ('PILOTID_LENGTH'), '0 ', STR_PAD_LEFT); } Do you have any suggestions? Thanks Quote Link to comment Share on other sites More sharing options...
Tom Posted January 14, 2014 Report Share Posted January 14, 2014 Find: <th><?php echo $ist->pilots_list ?></th> Replace: <td> <?php $codes = array(); foreach(explode(',', $ist->pilots_list) as $pilotcode){ $codes[] = PilotData::getPilotCode("VAR", $pilotcode); } echo implode(', ', $codes); ?> </td> Side note: You appear to have your <th> and <td> mixed up. Quote Link to comment Share on other sites More sharing options...
Tato123 Posted January 14, 2014 Author Report Share Posted January 14, 2014 Tanks Tom, Your help is Always needed Alberto Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.