Retrieve information from checkboxes php/mysql
<p>i have this code from which i print table rows and a checkbox with them, i need to print the checked rows in another php file.. how am i supposed to do that?</p>

<p>i need something like sql=select $checkbox1, checkbox2 or however it's better to do this....</p>

<pre><code>&lt;form action='report.php' method='post'&gt;

&lt;?php // Script 12.7 - sopping.php

$db = mysql_connect('localhost', 'root', '');
mysql_select_db('db_up', $db);

echo "&lt;table border='1' class='tabtext'&gt;";

$result = mysql_query("SELECT * FROM hostess");
$numrows = mysql_num_rows($result);
$numfields = mysql_num_fields($result);

// show headers
echo '&lt;thead&gt;&lt;tr&gt;';
for ($field = 0; $field &lt; $numfields; $field++) {
    $field_name = mysql_field_name($result, $field); // instead of $i
    echo '&lt;th&gt;&lt;label&gt;&lt;input type="checkbox" name="checkbox[' . $field_name . ']" value="1"/&gt; ' . $field_name . '&lt;/label&gt;&lt;/th&gt;';
}

echo '&lt;/tr&gt;&lt;/thead&gt;';

echo '&lt;tbody&gt;';
for ($row = 0; $row &lt; $numrows; $row++) {
    $data = mysql_fetch_assoc($result);
    echo '&lt;tr&gt;';
    for ($field = 0; $field &lt; $numfields; $field++) {
        $field_name = mysql_field_name($result, $field);
        if (isset($_POST['checkbox'][$field_name])) {
            echo '&lt;td&gt;' . $data[$field_name] . '&lt;/td&gt;';
        }
    }
    echo '&lt;/tr&gt;';
}
echo '&lt;/tbody&gt;';
echo '&lt;/table&gt;';


?&gt;
&lt;input type='submit' value='Submit' /&gt;
&lt;/form&gt;
</code></pre>
