Hi All,
I've made this code and it works, but the form has to be submitted twice before the changes are made to the read out.
I know it's an ordering issue, but I'm not sure of the solution.
Here's the snippet of my form code showing the checkboxes:
<?php
$ABquery=mysql_query("SELECT * FROM acts WHERE ClientID = '".$clientID."' AND ShowID = '".$SID."' ORDER BY TimeOnStage DESC");
while($ABrow=mysql_fetch_array($ABquery)) {
$ActID = $ABrow['id'];
$BandID = $ABrow['BandID'];
$Bresult=mysql_query("SELECT * FROM band WHERE id = '".$BandID."'");
$Brow=mysql_fetch_array($Bresult);
$ActArray[] = "Act".$ActID;
echo '<tr>
<td class="HDivider"><strong>'.$Brow['Band'].'</strong></td>
<td><input name="Act'.$ActID.'" type="checkbox" id="Act'.$ActID.'" value="del"></td>
</tr>';
}
//===============REMOVE ACTS===============================================
$i=0;
while($i<count($ActArray)) {
$Box = $ActArray[$i];
$ActPost = $_POST[$Box];
$Act = substr($ActArray[$i],3,999);
//echo $ActArray[$i].' = '.$ActPost.' = '.$Act.'<br>';
if ($_POST[$Box] == 'del') {
$ABquery=mysql_query("SELECT * FROM acts WHERE ClientID = '".$clientID."' AND id = '".$Act."'");
$ABrow=mysql_fetch_array($ABquery);
$BandID = $ABrow['BandID'];
$Bresult=mysql_query("SELECT * FROM band WHERE id = '".$BandID."'");
$Brow=mysql_fetch_array($Bresult);
mysql_query("DELETE FROM acts WHERE id='".$Act."' AND ClientID = '".$clientID."' LIMIT 1");
echo '<tr><td colspan="2">'.$Brow['Band'].' has been removed.<br /></td></tr>';
}
$i++;
}
//=========================================================================
?>
Basically, I want to be able to run the REMOVE ACTS part before reading out the checkboxes. I've tried simply putting this before the boxes are read out, but then it doesn't seem to find the $_POST's.
Anyone have any suggestions?
Thanks.