
March 22nd, 2004
01:16 PM
Neverside Newbie
Status: Offline!
inserting values of Checkbox
Hello,
I am developing a trainers database for my organization.
Sample Form
Database Schema
Table names:
CATEGORIES
cat_ID PK
trainer_ID FK
cat_name
FIELDS
field_ID PK
cat_ID FK
field_name
level
you can see in the sample form there are sooo many number of checkboxes in front of the FIELDS...how will i insert so many vaues at once and is their any other way of displaying so many checkboxes instead of hard coding them in html ....can i use loop for it
___________________
When it all becomes DARK
www.mobilevaganza.com

March 22nd, 2004
01:27 PM
You could use a loop to print them on the page:
<?php
//Number of listings on the page
$num_items = 30;
for($i = 0; $i < $num_items; $i++){
echo ' <input type="checkbox" value="' . $i . '" />';
}
?>
I suppose you could store the values of all the checkboxes in one field delimited by a comma and loop through them.
<?php
$result = mysql_query('SELECT checkbox_array FROM table');
while($r = mysql_fetch_array($result)){
$checkboxes = explode(',' $r['checkbox_array']);
foreach($checkboxes as $checkbox){
echo $checkbox;
}
?>
Didn't test it and there may be better ways of doing it as well.
___________________

| Come join the Purephotoshop.net forums