Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

74 users online



inserting values of Checkbox

inserting values of Checkbox

Currently viewing this thread: 1 (0 members and 1 guests)


ferhanz

ferhanz

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

Caged

Caged

Status: Offline!

You could use a loop to print them on the page:

PHP:

<?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:

<?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.

___________________

http://www.purephotoshop.com/images/pps_banner.jpg
| Come join the Purephotoshop.net forums

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0168 seconds.