如何从php中的mysql fetch获取变量值并使用它来创建另一个查询

This is my code with my output

 <?php
 $data = mysql_query("select * from request, users where request.user_id =  users.id and request.user_id = $user_id")  or die(mysql_error());
 Print "<table border cellpadding=3>";    
 while($info = mysql_fetch_array( $data ))
 {
     Print "<tr class='my_loans_tr'>"; 
     print "<td  class='detail'>"  .$info['loan_id'] . "</td> ";
     Print " <td class='admin_amount'>".$info['amount'] . "</td> "; 
     Print " <td class='admin_points'>".$info['points'] . "</td> ";  
     Print " <td class='admin_date'>".$info['req_date'] . " </td>"; 
     Print " <td class='admin_status'>".$info['status'] . " </td>"; 
     Print " <td class='admin_cancelled'>".$info['cancelled_loan'] . " </td></tr>"; 
     Print "</tr>"; 
 }  
 Print "</table>";
?>

output

enter image description here

The loan id is within the database, there is a second table named collected, that has info for each loan id (3 rows minimum of info based on same loan id)

How can I get each id from the query, click on it, get the current id and declare it as a value so I can execute another query which is,

select * from collected where loan id = "$loan_id clicked";

I have searched for javascript and jquery but I am not able to get it working with the post method, what is the best way to do this?