'Retrieving Specific MySQL Field Data in PHP Based on Primary Key Value using $_GET['ID']

I'm trying to find the correct way of pulling specific field data from a MySQL database. I am using the $_GET but it shows all the data and id. How can I get the data from a specific ID(primary keys).

        echo "<td>" .$view['Absence_Code']."</td>";
        
        echo "<td>" .$view['Details']."</td>";
        
        echo "</tr>";
    
        

2nd File

<body>

<?php
        
    

    $sql = "SELECT * FROM userapproval WHERE ID=$ID";

    $data = mysql_query($sql);
    
?>



</body>
</html>


Solution 1:[1]

Add report.php?ID=

 echo "<td>" .'<a href="report.php?ID='.$view['ID'].'">'.$view['ID'].'</a>'."</td>";

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 Krish R