i have the following code below on an admin page, where the user has selected a record to edit or delete.... the record is then edited or deleted depending on which button the user presses (i only have the delete button added so far)..... my query works, because id i put it in the code right after the table, it will delete the record.... the problem lies with the code for the delete button ..... basically when i press the delete button nothing happens, not an error, nor a record delete, just nothing..... any help with this would be greatly appreciated
<?php
include("other.inc");
include("accesscontrol2.php");
echo "<h3>Admin Control</h3>";
$connection = mysql_connect($host,$user,$password)or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection)or die ("Couldn’t select database");
$query = "SELECT * FROM houses WHERE houseID =\"{$_POST['edit_record']}\"";
$result = mysql_query($query) or die ("Couldn’t execute query.");
echo "<table cellpadding='5' border='1'>";
echo "<td valign='top' width='5%'><b>ID</b></td><td valign='top' width='15%'><b>Name</b></td>
<td valign='top' width='15%'><b>Address</b></td><td valign='top' width='10%'><b>City</b></td>
<td valign='top' width='5%'><b>Province</b></td><td valign='top' width='8%'><b>Postal Code</b></td>
<td valign='top' width='10%'><b>Phone Number</b></td><td valign='top' width='10%'><b>Alt. Phone Number</b></td>
<td valign='top' width='20%'><b>Description</b></td><td valign='top' width='10%'><b>Grouping</b></td>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
echo "<tr><td valign='top' width='5%'>\n";
echo "<name='edit_record' value='$houseID'\n";
echo ">$houseID</td>";
echo "<td valign='top' width='15%'>$name</td>
<td valign='top' width='15%'>$address</td><td valign='top' width='10%'>$city</td>
<td valign='top' width='5%'>$province</td><td valign='top' width='8%'>$postalCode</td>
<td valign='top' width='10%'>$phoneNum</td><td valign='top' width='10%'>$altPhoneNum</td>
<td valign='top' width='20%'>$description</td><td valign='top' width='10%'>$grouping</td>";
echo "</tr>";
}
echo "</table>";
echo "<input type='submit' name='action' method='post' value='delete'>";
if (isset($_POST["action"]))
{
if ($_POST["value"] == 'delete')
{
$delete_record = "delete from houses where houseID = $houseID";
$result_delete = mysql_query($delete_record) or die ("Couldnt execute delete.");
header("Location: delete_success.php");
}
}
?>
i guess i should mention that the 'edit_record' is getting passed from a form on a previous page (although im sure most of you figured that out)