I am passing the “id” value from one page media_main.php to another player.php via:
<a href="javascript:;" onclick="return popitup('player.php?pid=<?php echo ("$row->id");?>')" title="Listen">
On the player.php page I would like to select certain data WHERE the id equals that id that was passed. So far I have this:
$query = "SELECT id, media_date, media_title, given_by, filename FROM media WHERE id = ?? ORDER BY id DESC";
I’m not sure how to work the WHERE clause since it will change and not be a static number. I only want to select the data when the id to equal the passed id value.
Additionally to Clive’s response, if you know that the ID is only numerical, you can cast it to an Integer instead of escaping it.
If there is any erroneous input it will just cast it to 0.