•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,141 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,688 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2194 | Replies: 5
![]() |
•
•
Join Date: Jul 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: Jul 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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 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 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.
$data[$category][$subcategory][$entry]

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.
•
•
Join Date: Jul 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Jul 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Creating dynamic array structures (C++)
- ArrayList to multi-dimensional string array (C#)
- How to get value of selected dynamic checkboxes? (ASP.NET)
- URGENT - Reading from txt file into a 2 dimension array (Java)
Other Threads in the PHP Forum
- Previous Thread: Hide source of the page
- Next Thread: changing the .php extension and Apache mod_rewrite question



Linear Mode