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
The database where the url's are stored
How it look now
<?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.