显示基于主题的记录

时间:2018-03-28 13:28:37

标签: php html mysql function

按下topic时,我遇到了显示问题的问题。

我想要什么

我也希望显示具有正确topic_id的{​​{3}}中的记录,因此如果您点击某个主题,只需要显示具有该主题的“onderwerpen”(主题为荷兰语) topic_id

我的代码:

<div class="box box-info">
<div class="panel panel-default">
    <div class="panel-heading main-color-bg">
    <h3 class="panel-title">Topics</h3>
 </div>
<div class="panel-body">
<?php
 $toppics = $app->get_topics();
   foreach($toppics as $topic){
     echo '<div class="col-md-6">';
echo '<div class="well dash-box">';
echo '<h3>'.$topic['onderwerp'].'</h3><br>'; 
echo '<a href="####">'  .$topic['omschrijving'].'</a>';
echo '</div>';
echo '</div>';
}
?>

</div>
</div>
</div><!-- /.box -->

我使用的功能:

public function get_topics(){
   $getTopic = $this->database->query("SELECT * FROM topics ORDER BY id DESC");
    $topics = $this->database->resultset();

    return $topics;

 }

second database

The topic database

点击主题后它现在显示数据库中的所有“onderwerpen” 代码:

<?php

          $onderrwerp = $app->get_onderwerpen();
          foreach($onderrwerp as $onderwerp){
            echo '<div class="well well-sm">';
                if(file_exists('assets/images/profielfotos/'.$onderwerp['klant_id'])) { 
                    echo '<img class="img-circle" src="/assets/images/profielfotos/'.$onderwerp['klant_id'].'/'.$onderwerp['foto'].'" />';
                } else {
                    echo '<i style="font-size: 2.5em;" class="fas fa-user-circle"></i>';
                }
                echo '<b><a href="https:/####/reactie"> '.$onderwerp['onderwerpnaam'].'</b></a>'; 
                echo ' - ' . $onderwerp['voornaam'] . ' ' . $onderwerp['achternaam'];
                echo '</div>';
            }
        ?>

Get_onderwerpen功能:

    public function get_onderwerpen(){
        $getOnderwerp = $this->database->query("
        SELECT onderwerpen.*, klanten.foto, klanten.voornaam, klanten.achternaam FROM onderwerpen 
        LEFT JOIN klanten ON onderwerpen.klant_id=klanten.id
        ORDER BY id ASC");
        $onderwerpen = $this->database->resultset();

        return $onderwerpen;

    }

0 个答案:

没有答案