hi all , I have a table that shows all rows of a selected table . problem is that I want to delete marked rows from this table but this code is not working for me . updating code works fine but I can't delete selected rows .
<?
if($_SESSION["count"]!=0){
?>
<!-- begining of setting levels informations -->
<form name="form2" method="POST" dir="rtl" action="" style="font-family:'B_yekan';">
<input name="level" type="hidden" value="<? if(isset($_POST['level'])){ echo $_POST['level'];} ?>"/>
<div align="center" width = 615>
<table class="styled-table" cellspacing="0" width="800" border="1">
<tr>
<th width="10" scope="col" ></th>
<th width="60" scope="col">level</th>
<th width="60" scope="col">time</th>
<th width="60" scope="col">date</th>
<th width="42" scope="col">status</th>
<th width="54" scope="col">price</th>
<th width="42" scope="col">off</th>
<th width="54" scope="col">off 2</th>
<th width="60" scope="col">mark</th>
</tr>
<?php
$id = array();
while($rows=mysql_fetch_array($result)){
$id[]=$rows['id'];
?>
<tr>
<td align="center"><input class="styled-input" type="hidden" name="id[]" id="id" value= "<? echo $rows['id']; ?>" /></td>
<td align="center"><input class="styled-input" type="lev" name="lev" id="lev" value="<? echo $tbl_name; ?>" /></td>
<td align="center"><input class="styled-input" type="text" name="time[]" id="time" value= "<? echo $rows['time']; ?>" /></td>
<td align="center"><select class="styled-input" type="text" name="date[]" id="date" />
<option selected="selected" value="<? if($rows['date']=="1"){echo "1";}else{echo "0";}?>">
<? if($rows['date']=="1"){echo "even";}else{echo "odd";}?></option>
<option value="<? if($rows['date']=="1"){echo "0";}else{echo "1";}?>">
<? if($rows['date']=="1"){echo "odd";}else{echo "even";}?></option>
</select></td>
<td align="center"><select class="styled-input" type="text" name="act[]" id="act" >
<option selected="selected" value="<? if($rows['act']==1){echo "1";}else{echo "0";}?>">
<? if($rows['act']==1){echo "enable";}else{echo "disable";}?></option>
<option value="<? if($rows['act']==1){echo "0";}else{echo "1";}?>">
<? if($rows['act']==1){echo "disable";}else{echo "enable";}?></option>
</select></td>
<td align="center"><input class="styled-input" type="text" name="price[]" id="price" value= "<? echo $rows['price']; ?>" /></td>
<td align="center"><input class="styled-input" type="text" name="offprice[]" id="offprice"
value= "<? echo $rows['offprice']; ?>" /></td>
<td align="center"><input class="styled-input" type="text" name="off2price[]" id="off2price"
value= "<? echo $rows['off2price']; ?>" /></td>
<td align="center"><input class="styled-input" style="padding: 5px;width:20px" type="checkbox" name="checkbox[]"
id="checkbox[]" /></td>
</tr>
<?php
}//end of loop
?>
</table>
</div>
<input class="styled-button-8" type="Submit" value="submit" name="Submit" />
<input class="styled-button-8" type="Submit" value="delete" name="delete" />
<?php }//end of if ?>
</form>
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit']) && $_POST['Submit'] == 'submit')
{
for($i=0;$i<$_SESSION["count"];$i++)
{
$sql1="UPDATE `".$tbl_name."` SET `time`='".$_REQUEST['time'][$i]."',`date`='".$_REQUEST['date'][$i]."',`act`='".$_REQUEST['act'][$i]."'
, `price`='".$_REQUEST['price'][$i]."' , `offprice`='".$_REQUEST['offprice'][$i]."', `off2price`='".$_REQUEST['off2price'][$i]."'
WHERE `id`='".$_REQUEST['id'][$i]."' ";
$result1=mysql_query($sql1);
}
if(isset($result1)){
$_SESSION["count"]="";
?>
<script language="javascript">alert('all of the rows updated successfully');</script>
<?php
print(redirect('regmanage.php'));
}
?>
<!-- deleteing records -->
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['delete']) && $_POST['delete'] == 'delete')
{
for($i=0;$i<$_SESSION["count"];$i++)
{
if(isset($_POST['checkbox'][$i])){
$del_id = $_POST['checkbox'][$i];
$sql1 = "DELETE FROM `".$tbl_name."` WHERE `id`='".$_REQUEST['id'][$i]."' ";
$result1= mysql_query($sq1) or die(mysql_error());
}
}
}
if(isset($result1)){
?>
<script language="javascript">alert('the selected row deleted successfully.');</script>
<?php
print(redirect('regmanage.php'));
}
?>
<!-- end of setting infromations -->