Welcome Guest, Not a member yet? Register   Sign In
GROUP_CONCAT question
#1

Hello,
I have a question there and I have a problem with the "GROUP_CONCAT".
In my old code, this should merge the Rare names.

That is how it should look
   

This is how it looks without this "GROUP_CONCAT".
   

Let's go with that
   


PHP Code:
<table class="table">
    <
thead>
        <
tr>
            <
th>Nr.</th>
            <
th>Name der Karte (deutsch)</th>
            <
th>Name der Karte (englisch)</th>
            <
th>Rarität</th>
            <
th>Katogorie</th>
        </
tr>
    </
thead>
    <
tbody>
<?
php
    $SQL 
"SELECT
                tb_ygo_karten_kategorie_css,
                tb_edition_stats_nummer,
                tb_ygo_karten_stats_id,
                tb_ygo_karten_stats_name_de,
                tb_ygo_karten_stats_name_en,
                GROUP_CONCAT(db_rare.tb_rare_name SEPARATOR ', ') AS tbrana
            FROM
                db_edition_stats
            LEFT JOIN
                db_rare
                    ON
                        db_rare.tb_rare_id = db_edition_stats.tb_edition_stats_rare
            LEFT JOIN
                db_ygo_karten_stats
                    ON
                        db_ygo_karten_stats.tb_ygo_karten_stats_id = db_edition_stats.tb_edition_stats_karte
            LEFT JOIN
                db_ygo_karten_kategorie
                    ON
                        db_ygo_karten_kategorie.tb_ygo_karten_kategorie_id = db_ygo_karten_stats.tb_ygo_karten_stats_kategorie
            WHERE
                db_edition_stats.tb_edition_stats_edition = "
.$get_edition['tb_edition_id']."
            ORDER BY
                db_edition_stats.tb_edition_stats_nummer"
;
    
$query $this->db->query($SQL);
    foreach (
$query->result() as $karte)
        {
?>
        <tr class="<?php echo $karte->tb_ygo_karten_kategorie_css?>">
            <td><?php echo $karte->tb_edition_stats_nummer?></td>
            <td><a href="<?php echo base_url(); ?>pages/karte/<?php echo $karte->tb_ygo_karten_stats_id?>"><?php echo $karte->tb_ygo_karten_stats_name_de?></a></td>
            <td><a href="<?php echo base_url(); ?>pages/karte/<?php echo $karte->tb_ygo_karten_stats_id?>"><?php echo $karte->tb_ygo_karten_stats_name_en?></a></td>
            <td><?php echo $karte->tbrana?></td>
            <td><?php// echo $pn[$key]['tb_karten_kategorie_name_de'];?></td>
            <td><a href="https://de.yugiohcardmarket.eu/Products/Singles/Code+of+the+Duelist/<?php// echo urlencode($pn[$key]['tb_karten_stats_name_en']);?>"><button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>&nbsp;Cardmarket</button></a></td>
        </tr>
<?php
        
}
?>
    </tbody>
</table> 

PS. If possible answer in German
Reply
#2

For one you should not be using database code in your views.

See the CodeIgniter Users Guide HTML Table Class Library.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 09-04-2017, 06:41 AM by php_rocs.)

@Germanikus, (SUGGESTION) I always recommend that you run your SQL statement within the Database itself (first). By doing this before you enter it into the code you will know that it works.

I also agree with InsiteFX.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB