so i have a DB with an admin funciton... the admin searches for the record to edit or delete, then chooses the record from the returned search list via a radio button... this radio button is passed to the following page (code is after this) as edit_record... the record is then shown in a table... there will eventually be an edit and a delete button, but so far i only have put the delete button on the page.... my problem is that when i click on the delete button, the record does not get deleted... im not sure what im doing wrong here.... any help would be greatly appreciated, thx in advance
<?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>";
$delete_houseID = '$houseID';
}
echo "</table>";
echo "<input type='submit' name=action value=delete>";
if (isset($POST["action"]))
{
if ($POST["action"] == 'delete')
{
$delete_record = "delete from houses where houseID = '$delete_houseID'";
$result_delete = mysql_query($delete_record) or die ("Couldnt execute delete.");
//if($result_delete)
// want some kind of redirect here to a page that says "the record has been deleted
// i cannot use a redirect because header info has already been sent with this page
// when i set up the table... the only solution i can think of is a popup javascript
// is there another way to do a redirect after sending header info?
}
}
?>