CODE
<?php //set variables to connect to the database $hostName = "(FILL IN HOSTNAME FOR DB)"; $userName = "(FILL IN USERNAME FOR DB)"; $password = "(FILL IN PASSWORD FOR DB)"; $dbName = "(FILL IN DB NAME)"; // make connection to database mysql_connect($hostName, $userName, $password) or die( "Unable to connect to host $hostName"); mysql_select_db($dbName) or die("Unable to select database $dbName"); ?> <table> <tr> <td>Display</td> <td>Checkbox</td> </tr> <?php //query the database for all relevant rows to be updated $query = "SELECT * FROM (FILL IN TABLE NAME) WHERE (FILL IN FIELD NAME) = '(FILL IN RESTRICTION)'"; $result = mysql_query($query); $number = mysql_numrows($result); //set up a while loop to display all of the rows and checkboxes $i=0; while($i<$number) { $id_variable = mysql_result($result,$i, 'id_field'); $display_variable = mysql_result($result,$i, 'display_field'); ?> <tr> <td><?php echo $display_variable; ?></td> <td> <!--name the checkbox with the id variable to make each one unique for the following process page--> <input type="checkbox" name="cb_<?php echo $id_variable;?>"/> </td> </tr> <?php $i++; } ?> <tr> <td colspan="2" align="right"> <input type="submit" name="button" value="Submit" /> </td> </tr> </table>
DISPLAY
| Display | Checkbox |
| Display Name 1 | |
| Display Name 2 | |
| Display Name 3 | |
| Display Name 4 | |
| Display Name 5 | |
| Display Name 6 | |