I've set up an indented list created with a standard parent/child script to reveal user assignments to web pages. In the edit users page we can delete assignments to the list by checking boxes and running the delete form.
Here's the odd behavior: When I remove the indenting from the list I can select any check box or multiple check boxes and the access is removed. However, if I implement the indenting using the code below when I check a box the next box in the list is deleted. If there's a child in the list and I try and delete the child nothing happens.
For example if the list is:
When I select Page 4 to delete nothing happens. If I select Page 2 and delete then Page 1 is removed.
Here's the code:
PHP Code:
<?php
// Check if bizCat delete button active, start this
if(isset($_POST['delete']) && $_POST['checkbox'] <> NULL){
$ids = implode(', ', $_POST['checkbox']);
$sql = "DELETE FROM userBizCats WHERE id IN($ids)";
$result = mysql_query($sql);
if($result){
$pgID = $row_pageRS['id'];
header("location: docsTest.php?recordID=$pgID");
exit;
}
}
?>
// -------- The code above is before the HTML, the code below is in a div tag in the body ----------
<?php
echo '<form name "deleteForm" method="post" id="deleteForm">';
echo '<p><input name="delete" type="submit" id="delete" formmethod="POST" value="Delete Selected BicCats" /></p>';
$parentid = 0; // assuming that 0 is the main category.
get_sub_catsBC($parentid);
function get_sub_catsBC($parentid) {
$sql = "SELECT
bizCats.id AS bcSN, bizCats.bcID, bizCats.bcName,
userBizCats.bizCatID,
users.id
FROM bizCats, userBizCats, users
WHERE bizCats.bcID = ".$parentid."
AND userBizCats.bizCatID = bizCats.id
AND users.id = '35'
";
$result = mysql_query($sql);
echo '<ul class="aqtree3clickable">';
if (mysql_num_rows($result) > 0) {
while ($rec = mysql_fetch_assoc($result)) {
$delID = $rec['bcSN'];
echo '<input type="checkbox" name="checkbox[]" id="checkbox[]" value=', $delID , '>SN: ', $delID, ' - ', $rec['bcName'];
get_sub_catsBC($rec['bcSN']);
}
}
echo '</ul>';
echo '</form>';
}
?>
Simple removing the get_sub_catsBC and parents ID lines from the code produces a non indented list and then all the delete functions work just fine.
I hope that I'm not completely barking up the wrong tree here....