PHP checkbox to select and update multiple rows
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11261068/check-box-value-doesnt-come">Check box value doesn&#39;t come</a>  </p>
</blockquote>



<p>I'm going to select multiple rows by checkbox, but the checkbox value doesn't take to the variable $del_id. It is always NULL. Why is that?</p>

<pre><code>&lt;td&gt;
    &lt;input type="hidden" name="id" id="id" value="&lt;?php 
        echo $row["file_serial_id"]; 
    ?&gt;" /&gt;

    &lt;input type="checkbox" name="checkbox[]" id="checkbox[]"  value="&lt;?php 
         echo $row['file_serial_id']
    ?&gt;" /&gt;
&lt;/td&gt;
</code></pre>

<p>Somewhere in the form's script...</p>

<pre><code>if (isset($_POST['send_btn']) and $_POST['send_btn']=="Send") {

    $checkbox = isset($_POST['checkbox']) ? $_POST['checkbox'] : 0; 
    $checkbox = $_POST['checkbox']; //from name="checkbox[]"
    $countCheck = count($_POST['checkbox']);

    for($i=0; $i&lt;$countCheck; $i++) {
        $del_id = $checkbox[$i];
        $sql2 = "UPDATE retained_file_mst SET mark_to_dispose=1 WHERE  file_serial_id='$del_id'";
        $result2 = mysql_query($sql2,$conn);
    }

    //  if successful redirect to delete_multiple.php
    if ($result2) {
        echo "success";
    } else {
        echo "error";
    }
}
</code></pre>
