Checkbox in a while loop
<p>I am trying to create a function where users can check a message to delete. Obviously if more than one message is checked, they will all be deleted.</p>

<p>I have the following code</p>

<pre><code>&lt;form action="process.php" method="post"&gt;
    &lt;input type="hidden" name="deleteMessages" /&gt;
    &lt;?php
    while($row=mysql_fetch_assoc($q))
    {
        if($row['to_viewed'] == 0)
        {
        ?&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;input type="hidden" name="check_box_1" value="0" /&gt;
                &lt;input type="checkbox" name="check_box_1" value="1" /&gt;
            &lt;/td&gt;
            &lt;td&gt;&lt;b&gt;&lt;a href='&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?p=view&amp;mid=&lt;?php echo $row['id']; ?&gt;'&gt;&lt;?php echo $row['title'] ?&gt;&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;
            &lt;td&gt;&lt;b&gt;&lt;a href='&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?p=view&amp;mid=&lt;?php echo $row['id']; ?&gt;'&gt;&lt;?php echo $row['from']; ?&gt;&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;                
            &lt;td&gt;&lt;b&gt;&lt;?php echo $row['created']; ?&gt;&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?php
        }
        else if($row['to_viewed'] == 1)
        {
        ?&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;input type="hidden" name="check_box_1" value="0" /&gt;
                &lt;input type="checkbox" name="check_box_1" value="1" /&gt;
            &lt;/td&gt;
            &lt;td&gt;&lt;a href='&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?p=view&amp;mid=&lt;?php echo $row['id']; ?&gt;'&gt;&lt;?php echo $row['title'] ?&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;td&gt;&lt;a href='&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?p=view&amp;mid=&lt;?php echo $row['id']; ?&gt;'&gt;&lt;?php echo $row['from']; ?&gt;&lt;/a&gt;&lt;/td&gt;                
            &lt;td&gt;&lt;?php echo $row['created']; ?&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?php
        }
    }
    ?&gt;
    &lt;input type="submit" value="Delete All" /&gt;
    &lt;/form&gt;
</code></pre>

<p>I want to pass the checkbox through and if the value is 1, process it and delete it.
But how would I achieve this with mulitple messages no matter if there is one message or ten?
Thanks</p>
