If someone could help me, I'd sure appreciate it. I've spent the better part of two hours trying to figure this out and still no success.
Here's what I'm trying to do - Should be simple:
The user is presented with a form to delete a category. The form contains a drop down selection box of categories. Once they select the category and press submit, it should delete the category from the Categories Table.
I've tried using a input type="hidden" value=<?php echo $recordid; ?> to pass the contents to the Submit code but that doesn't work. I also tried assigning the contents ... $recordid = $rowCategories['ID']; as it is now but that doesn't work either.
Also, I searched the manual for functions on select or selected....I don't know maybe I'm searching in the wrong place.
When the form is displayed, the selection box contains a list:
29-Category1
43-Category2
51-Category3
Where the recordid is the number
Bill
<?php
$sqlCategories = "Select ID, NAME FROM CATEGORIES ORDER BY NAME";
$myCategoriesresult=mysql_query($sqlCategories);
while($rowCategories = mysql_fetch_array($myCategoriesresult))
{
$SelectBoxCategories[] = "\n<option value\"".$rowCategories['ID']." ".$rowCategories['NAME']."\">".$rowCategories['ID']."--".$rowCategories['NAME']."</option>";
$recordid = $rowCategories['ID'];
}
?>
<form action="<?=$PHP_SELF ?>" method=post>
<tr><td align=left>
<span class=s1>
Select a Category to be deleted
</span> </td>
<td align=left>
<select name="PCategories">
<?php
foreach($SelectBoxCategories as $option)
{
echo $option."\n";
}
?>
</select>
</td>
<tr><td colspan=4> </td></tr>
<tr><td colspan=2><br><br><br></td></tr>
<tr><td align=right><input type="submit" name="submitlist" value="Submit List"></td><td align=left><input type=reset></td></tr>
<tr><td colspan=2><br><br><br></td></tr>
<tr><td colspan=2><br><br><br></td></tr>
<tr><td align=left></td></tr>
</form>
</table>
<?php
if ($submitlist == "Submit List")
{
$result = "DELETE FROM CATEGORIES WHERE ID='$recordid'";
mysql_query($result);
// send the result to the confirmation page.
print("<script>
location.href=\"deletecategory2.php?R6427=$PCategories\";
</script>
");
}
?>