I have a table that I fill with records from the database. What I want to do when the view button is clicked is to be able to get the ID of the row so that I can call on the oth
You could use a hidden input element, like this:
"<input type=hidden id='rowid' value=".row['ID'].">";e
You could make little forms for each button but I prefer hyperlinks that I then style to look like buttons:
<style type="text/css">
.buttonize {
text-decoration: none;
border: 1px solid #ccc;
background-color: #efefef;
padding: 10px 15px;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
text-shadow: 0 1px 0 #FFFFFF;
}
</style>
<table border="1" cellpadding="5" cellspacing="2" width="600">
<tr>
<th>ID</th>
<th>Username</th>
<th>Email</th>
<th>Telephone</th>
<th>Date Registered</th>
<th>Member Details</th>
</tr>
<?php
require('db_connection.php');
$query="SELECT ID,Username,Email,Telephone,RegisterDate FROM Members";
$result=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
echo "</td><td>";
echo $row['ID'];
echo "</td><td>";
echo $row['Username'];
echo "</td><td>";
echo $row['Email'];
echo "</td><td>";
echo $row['Telephone'];
echo "</td><td>";
echo $row['RegisterDate'];
echo "</td><td>";
print '<center><a href="view.php?id='.$row['ID'].'" class="buttonize">View</a></center>';
echo "</td></tr>";
}
?>
You can do more with the CSS but that should give you the right idea.
Send your row ID via button HTML
<button type="submit" id="" title="" onClick="high('a<?php echo $i;?>')" >
JS:
Use js to catch id
function high(id)
{
alert(id);
}