I have a series of links that pass information to a new page to run a MySQL query. This is one of the links from source code:
<a class="bloglink" href="parknews.php?tpf_news.park_id=5">
and this is the code that generates the links:
<a class="bloglink" href="parknews.php?tpf_news.park_id=<?php echo $row2['park_id'];?>">
<?php echo $row2['name']; ?>
</a>
The query that uses that info is here:
$park_id = $_GET['tpf_news.park_id'];
$sql = 'SELECT headline, story, DATE_FORMAT(date, "%d-%M-%Y") AS date, name
FROM tpf_news
INNER JOIN tpf_parks ON tpf_news.park_id = tpf_parks.park_id WHERE tpf_news.park_id = $park_id ORDER BY date DESC' ;
This causes this error to display:
Error fetching news: SQLSTATE[42S22]: Column not found: 1054 Unknown column '$park_id' in 'where clause'
I can't work out why it is not working. If in the query I replace WHERE tpf_news.park_id = $park_id
with WHERE tpf_news.park_id = 6
(or any other number), it works fine.
Any ideas?