'How to get the ID of the link in another page in php

I like to catch the id of below tag in show.php file once the link is clicked... I have already got the href name in show.php

<?php

if (isset($_GET['submit'])) {
  $choice=$_GET['prod'];

  $dbc=mysqli_connect('localhost','root','','online_shopping') or die('Connection Error');

  $query1="SELECT name, id from ".$choice; $result1=mysqli_query($dbc,$query1) or die('Error querying Database');

  echo "<h1>List of available products in your category</h1><hr>"; 

  while($row = mysqli_fetch_array($result1)) { 
    $id=$row['id'];
?>
<a style="font-size:18px; text-decoration:none; text-align:center; color:#09F;" href="show.php?ref=<?php echo $row['name'];?>" id="<?php echo $id;?>"><?php echo $id;echo '.'.$row['name']; echo '</a>'; 


Solution 1:[1]

The id attribute is only used client side, so short of using JavaScript to modify the URL — you can't.

Put the data in the URL in the first place … and exercise some safety over adding data to URLs and HTML.

<a href="show.php?ref=<?php 
  echo htmlspecialchars(urlencode($row['name']));
?>&id=<?php 
  echo htmlspecialchars(urlencode($id));
?>" 
id="<?php 
  echo htmlspecialchars($id);
?>"><?php 
  echo htmlspecialchars($id) . '.' . htmlspecialchars($row['name']); 
?></a>

Solution 2:[2]

I believe you're looking for $_GET.

<?php

   //show.php?ref=5&id=10

   echo $_GET['ref'];
   //5

   echo $_GET['id'];
   //10

?>

Solution 3:[3]

<?php echo $_GET["id"]; ?>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Quentin
Solution 2 Kermit
Solution 3 Dejan Biljecki