I am trying to delete some rows when users check them with check button. I have created a button called delete, but I have a problem. It said to me that variable delete that I use here
// Check if delete button active, start this  if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM Aktivitet WHERE Id_Akt='$del_id'"; $result = mysql_query($sql); } is not defined... But why because I have declared it as the name of Delete button...here I have created the Delete button;
  print("<tr>");
    print("<td><input name='delete' type='submit' id='delete' value='Delete'></td>");
    print("</tr>");
Please can you help me? What can I do? My php file is below:
<?php
$con = mysql_connect('127.0.0.1','root','');
if (!$con)
  {
  die('Lidhja me databazen nuk mund te kryhet' .mysql_error(). ' </body></html>');
  }
if(!mysql_select_db("Axhenda",$con))
die('Nuk mund te hapet databaza Axhenda'.mysql_error(). '</body></html>');
$result = mysql_query("SELECT * FROM Aktiviteti where Data= '$_POST[dataoutput]'");
mysql_close($con);
    ?>
<div class="title"> Aktivitetet per daten <?php print ("$_POST[dataoutput]"); ?></div>
<table> 
<?php
  print("<th >");
   print("<form name='form1' method='post' action=''>");
  print("<td>Emertimi takimit</td>");
   print("<td>Pershkrimi takimit</td>");
    print("<td>Oraa takimit</td>");
    print("</th >");
while($rows=mysql_fetch_row($result))
{
if (!empty($rows))
{
     print("<tr >");
print("<td align='center' bgcolor='#FFFFFF'><input
 name='checkbox[]' type='checkbox' id='checkbox[]' value='$rows[0]'></td>");
print("<td bgcolor='#FFFFFF'>$rows[2]</td>");
print("<td bgcolor='#FFFFFF'>$rows[3]</td>");
print("<td bgcolor='#FFFFFF'>$rows[5]</td>");
print("</tr>");
    }
 else 
 echo "ska aktivitet";
}
print("<tr>");
print("<td><input name='delete' type='submit' id='delete' value='Delete'></td>");
print("</tr>");
?>
<?php
// Check if delete button active, start this 
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM Aktivitet WHERE Id_Akt='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php 
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
}
}  
print("</form>");
?>
</table>
I modified the function like below, but it still dont delete anything:
if(isset($_POST['delete'])){
    $checkbox = $_POST['checkbox'];
$count = count($checkbox);
    for($i = 0; $i < $count; $i++) {
        $id = (int) $checkbox[$i]; 
        if ($id > 0) { // and check if it's bigger then 0
            mysql_query("DELETE FROM Aktiviteti WHERE Id_Akt= $id");
        }
    }
}
please help me..
 
     
     
     
    