PHP/MySQL Row Buttons
<?php
$query = "SELECT * FROM table1";
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
echo "<TABLE BORDER = '1'>";
echo "<TR>";
echo "<TH>Unique ID</TH><TH>URL</TH><TH>First Name</TH><TH>Last Name</TH><TH>Mail</TH><TH>Time Entered</TH>";开发者_运维百科
echo "</TR>";
while ($row = mysql_fetch_array($result))
{
echo "<TR>";
echo "<TD>",
$row['Unique_ID'], "</TD><TD>",
$row['url'], "</TD><TD>",
$row['fname'], "</TD><TD>",
$row['lname'], "</TD><TD>",
$row['mail'], "</TD><TD>",
$row['time'], "</TD>";
echo "</TR>";
}
echo "</TABLE>";
echo "<br>";
?>
I have the above piece of code, and I would like to automatically insert buttons at the end of each row: edit & delete. Please help?
Also, in the same piece of code-these buttons-I would like to create them as simple MySQL quereid, but then ho will the script know for which row to apply the queries?
echo '<td><form action="/delete.php" method="POST">';
echo '<input type="hidden" name="id" value="'.$row['Unique_ID'].'">';
echo '<input type="submit" value="Delete"></form>';
echo '<form action="/edit.php" method="GET">';
echo '<input type="hidden" name="id" value="'.$row['Unique_ID'].'">';
echo '<input type="submit" value="Edit"></form></td>';
Something like that?
EDIT: cleaned up a bit for clarity
精彩评论