显示基于URL的记录

I have a problem with getting the right records out of the database. look at the img. When I click on the left on a board it will put that in the url. Like this https://####/boards/stel-jezelf-voor. Now I want it to display only the records that have that url.

The question summary: I want to display the records based on the url. Example: When I press nieuws & events and it will only display the 'topics' with that url

the topic database

enter image description here

The database where the url's are stored

enter image description here

How it look now

enter image description here

<?php
  $toppic = $app->get_topics();
     foreach($toppic as $topic){
       echo '<a href="https://####/reactie"> <div id="topic">';
       echo '<div id="topicimg">';
        if(file_exists('assets/images/profielfotos/'.$topic['klant_id'])) { 
           echo '<img class="img-circle" src="/assets/images/profielfotos/'.$topic['klant_id'].'/'.$topic['foto'].'" />';
        } else {
           echo '<i class="fa fa-fw fa-user img-circle"></i>';
        }
     echo '</div><div id="topictekst">';
     echo '<b>'.$topic['topicnaam'].'</b>'; 
     echo ' - ' . $topic['voornaam'] . " " . $topic['achternaam'] ;
     echo '<span style="float:right; margin-top:15px; margin-left:5px;">'.implode($app->count_reactie($topic['id'])) .' reacties</span> <span style="float:right; color:lightgrey; margin-top:15px"class="fa fa-comment"></span>';
      echo '<hr><span class="badge bg-red">' . implode($app->boards($topic['board_id'])) . '</span>';
      echo ' laatste reactie: ' .$app->tijd_reactie($topic['id']) . ' door ' .$app->reactieDoor($topic['id']);
      echo '</div></div></a>';
    }
?>

The function:

public function get_topics(){
        $getTopic = $this->database->query("
        SELECT topics.*, klanten.foto, klanten.voornaam, boards.topic, ledenpagina.ledenpagina_id, klanten.achternaam FROM topics 
        LEFT JOIN ledenpagina ON ledenpagina.ledenpagina_id = topics.ledenpagina_id
        LEFT JOIN klanten ON topics.klant_id=klanten.id
        LEFT JOIN boards ON topics.board_id=boards.id
        WHERE ledenpagina.ledenpagina_id=:ledenpagina_id 
        ORDER BY id ASC");
        $this->database->bind(":ledenpagina_id", $_SESSION['ledenpagina_id']);

        $topics = $this->database->resultset();

        return $topics;

    }

I hope that this is enough information so someone can help me, This is my first question so don't be to hard on me and tell me if I am missing something.

I would like to see where exactly you're assigning ledenpagina_id and if you're not making this too complex. You seem to be pulling a lot of data from the database, and i don't think you'd need this. wouldn't it be easier to write a function that just finds the id of the topic you need, and pull only the data you need on that topic, using the result of that? also, where is that session variable set? And what framework are you in? I think most entity frameworks have built in functionality that doesn't require you writing those SQL statements. My apologies that this is not a comment, i need more reputation points for that.