When the user is able to click on things this is no longer PHP, this is HTML and javascript. PHP is executed on the server, the result of this execution is the HTML+CSS+Javascript that the user downloads to its pc.
From what you descrived you need to generate the correct HTML+javascript using the PHP variables you get from the database, for example:
echo "<a href=\"your_php_page.php\">Click me</a>";
This will display a link, but it will not pass any parameters, if you want to pass a id using GET you should do it like this:
$id=1234;
echo "<a href=\"your_php_page.php?id=$id\">Click me</a>";
In the your_php_page.php you can receive this id like this:
$id=$_GET['id'];
//if you are going to use this in a query you should do something like this to prevent injection
$id=$mysqli->real_escape_string($id);
If you want to use POST, you will have to submit a form or use AJAX, but that's more advanced, you should focus on making it work using GET.