Reputation: 6679
When I click one of the following links, I want to go to categorie.php, but depending on what link I click, I want to show a different kind of information. So the query would be if I click the first link for example in categorie.php: SELECT * from advertenties where maat=50;
<a href=categorie.php>50(0-1 mnd)</a><br>
<a href=categorie.php>56(1-2 mnd)</a><br>
<a href=categorie.php>62(2-4 mnd)</a><br>
<a href=categorie.php>68(4-6 mnd)</a><br>
<a href=categorie.php>74(6-9 mnd)</a><br>
<a href=categorie.php>80(9-12 mnd)</a><br>
<a href=categorie.php>86(1-1,5 jaar)</a><br>
Now I have no idea how to get the value of the link
I did make a php page that looks alot like this but is a little bit different which looks like this:
while ($thread = mysqli_fetch_assoc($sql_result)) {
echo <<<EOT
<table>
<th><a href=thread.php?thread_id={$thread['thread_id']}> {$thread['title']} </a></th>
</table>
EOT;
}
But this is just showing all the topics of a forum.
At my page I want to show some standard values, and show everything that has that value as a tag. How do I accomplish this?
Upvotes: 0
Views: 72
Reputation: 46650
Add a parameter to the url:
<a href="categorie.php?cat=50">50(0-1 mnd)</a><br>
Then access count using $_GET['cat']
Within your sql query use the value of cat to access the data you want:
Assuming your using PDO
<?php
$sql = 'SELECT * from advertenties WHERE maat = :cat';
$stmt = $this->db->prepare($sql);
$stmt->execute(array(':cat'=>$_GET['cat']));
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
Upvotes: 3