Hi all!

I am totally stumped and am hoping someone can help me. I have some data in a database that I will be using to create checkboxes. However, since different data will be pulled out depending on what the user chooses, I want to be able to create the name of my checkboxes based on what they want (which is also in a database), ie instead of hardcoding name="checkbox[]", I want to be able to make it name="whatcomesoutofdb[]"

Does that make sense? I cant seem to figure out how to make it work and maybe it's not possible. I've tried a variable of variables but that doesn't seem to work for array. Any help would be great!

Thanks!

Why is the name of your internal variable for storing the checkbox array important to what the user sees? I guess I'm missing that part.

Thanks for your reply! Ah, I was thinking that I would name the internal array variable with key IDs that correspond to the entries in my database. That way when I get the results, I'll be able to insert into my database easily. At least that's what I thought.

I don't know if this will clarify much, but here is what I'm trying to do. I'm creating a questionnaire and all of the items that a user can select are stored in a database. I then want to be able to record what each user selected and dump it out later by user. The questionnaire is grouped by different categories and subcategories, which is what each array variable will hold. Ideally, I'd like to just create one page that will ask the right question based on the $_GET variable (which will be the category) passed in the URL. It worked perfect when I hardcoded everything, but a database will make managing my data a lot easier.

I think my problem is that I have 4 subcategories per category and would like it all to show up on one page. I suppose if I just had one subcategory per page, this wouldn't be a problem.

Man, I probably just made this more confusing.

I suppose you could stuff all of the data into something like

$data[$category][$subcategory][$entry]

but I'm not sure if that will make it easier or more difficult for you to manage :)

The display part would be pretty easy at that point, since it only requires a series of nested for loop to generate output. Not knowing the database structure it's harder to say if you can push the data into the structure quite as easily from your queries.

Just a thought.

I think I experinced your problem, so try my remedy :
1st define a variable ase name of your checkbox
2nd assign what else that pulled out ... to that varialbe, thus you have a check box which has different name depending on what the user chooses.
like this:

$query = select * from ... ;
$result = mysql_query( $query, "sqlLink" );
$getResult = mysql_fetch_array( $result );

name = $getResult["..."];

I hope it helps to you

I think I experinced your problem, so try my remedy :
1st define a variable ase name of your checkbox
2nd assign what else that pulled out ... to that variable, thus you have a check box which has different name depending on what the user chooses.
like this:

$query = select * from ... ;
$result = mysql_query( $query, "sqlLink" );
$getResult = mysql_fetch_array( $result );

name = $getResult["..."];

I hope it helps to you

I am not able to retrieve check boxes from the databases. I have done as far as what the thread says.

I am not able to retrieve the check boxes from the database for some reason.. I have done stuff so far as what this thread reads.

This article has been dead for over six months. Start a new discussion instead.