title: PHP to delete SQL row with multiple checkboxes
body: <p>I am trying to delete multiple rows with chekboxes. Below is my code </p>
  
  <pre><code>      &lt;?php
  $host="localhost"; // Host name 
  $username="****"; // Mysql username 
  $password="****"; // Mysql password 
  $db_name="****"; // Database name 
  $tbl_name="****"; // Table name 
  
  // Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  $result = mysql_query("SELECT * FROM members WHERE dealer='Panzer Protection'");
  ?&gt;
  &lt;form name="form1" method="post" action=""&gt;
        &lt;?php
  while($rows=mysql_fetch_array($result)){
  ?&gt;
        &lt;tr&gt;
          &lt;td bgcolor="#666666"&gt;&lt;input name="checkbox[]" type="checkbox" id="checkbox[]"    
  value="&lt;? echo $rows['member_id']; ?&gt;"&gt;&lt;/td&gt;
          &lt;td bgcolor="#666666"&gt;&lt;? echo $rows['member_id']; ?&gt;&lt;/td&gt;
          &lt;td bgcolor="#666666"&gt;&lt;center&gt;
            &lt;? echo $rows['member_msisdn']; ?&gt;&lt;/td&gt;
          &lt;td bgcolor="#666666"&gt;&lt;center&gt;
            &lt;? echo $rows['member_name']; ?&gt;&lt;/td&gt;
          &lt;td bgcolor="#666666"&gt;&lt;div align="center"&gt;&lt;? echo $rows['dealer']; ?&gt;&lt;/div&gt;   
  
   &lt;/td&gt;
          &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;a href="control_clientinfo.php?member_id=   
  &lt;? echo $rows['member_id']; ?&gt;" class="update"&gt;Look Up&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?php
  }
  ?&gt;
  
  &lt;tr&gt;
  &lt;td colspan="6" align="center" bgcolor="#FFFFFF"&gt;&lt;input name="delete" type="submit"     
  id="delete" value="Delete"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/form&gt; //Forgot form close in past
  &lt;?php
  
  // Check if delete button active, start this 
  if($_POST['delete']){
  for($i=0;$i&lt;$count;$i++){
  $i = 0;
  while(list($key, $val) = each($_POST['checkbox'])) {
  $sql = "DELETE FROM $tbl_name WHERE id='$val'";
  mysql_query($sql);
  $i += mysql_affected_rows();
  }
  }
  // if successful redirect to 
  if($result){
  echo "&lt;meta http-equiv=\"refresh\" content=\"0;URL=control_clientlistdel.php\"&gt;";
  }
  }
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>It shows me the list i call and i can tick the boxes. If i hit delete button it just refreshes the screen and the one i ticked is still there</p>