This is my table
http://postimg.org/image/vb9du3ikl/
All i want to do is when i click "CLICK HERE" i will get the LOAN ID value for example when i click "CLICK HERE" on the first row i will get 201410000account-00002. I've been searching the web not still the codes does't work :( i've been trying to figure this out for a week now :( please help codes guru
Here is my php to generate the table
$myquery="select loan.loanid,loanamount,interest,totalamount,duedate,paymenttype,remarks from loan,member,account where loan.accountid=account.accountid and account.memberid=member.memberid and account.memberid='".$mid."'";
$results=mysql_query($myquery);
echo "<table id='tableID' border='1' align='center'>";
echo "<tr style='background-color:#F60;color:white' align='center'><td>Loan ID</td><td>Loan Amount</td><td>Interest</td><td>Total Loan</td><td>Due Date</td><td>Payment type</td><td>Status</td><td>Loan Info</td></tr>";
while($rs=mysql_fetch_array($results))
{
if($rs['remarks']=='done')
{
echo"<td align='center' > ".$rs['loanid']."</td>";
echo"<td align='center'>".number_format($rs['loanamount'], 2, '.', ',')."</td>";
echo"<td align='center'>".number_format($rs['interest'], 2, '.', ',')."</td>";
echo"<td align='center'>".number_format($rs['totalamount'], 2, '.', ',')."</td>";
echo"<td align='center' > ".$rs['duedate']."</td>";
echo"<td align='center' > ".$rs['paymenttype']."</td>";
echo"<td align='center' >Fully Paid</td>";
print"<td style='color:red' align='center' onClick='loadXMLDoc()' > <a>CLICK HERE</a></td>";
$loanID=$rs['loanid'];
echo "<tr>";
}else{
echo"<td align='center' > ".$rs['loanid']."</td>";
echo"<td align='center'>".number_format($rs['loanamount'], 2, '.', ',')."</td>";
echo"<td align='center'>".number_format($rs['interest'], 2, '.', ',')."</td>";
echo"<td align='center'>".number_format($rs['totalamount'], 2, '.', ',')."</td>";
echo"<td align='center' > ".$rs['duedate']."</td>";
echo"<td align='center' > ".$rs['paymenttype']."</td>";
echo"<td style='color:red'align='center' >On Going</td>";
print"<td style='color:red' align='center'><a href='index.php'>CLICK HERE</a></td>";
$loanID=$rs['loanid'];
echo "<tr>";
}
}
echo "</table>";
?>
i tried this jq earlier but it does't work :(
<script type="text/javascript">
$('tr').each(function() {
$(this).click(function() {
var selectedTd = $(this).children('td:first-child').text();
alert(selectedTd);
});
});
</script>