Hello all!
I'm creating a parametric search page that has groups of checkboxes on it. All the info is served from a DB. I have a "fieldtable" that has a list of column names in the "maintable". The ENUM values for each column are picked out of the Main Table and a checkbox is made for each.
So something like
Some table field:
CHK Enum 1
CHK Enum 2
This repeats for all the main table fields listed in fieldtable. This makes for very short code that creates a large page.
The name that I want to give the return value is also puled from the "fieldtable". The data is posted back using "someval[]" syntax in the checkbox code so it's posted back as an array.
$name = $sqlresult[fields_returnval];
$name= $name."["."]";
<INPUT TYPE=CHECKBOX name=\"$name\" value=\"$option\">$option
Now to my question. I got up to the point where I want to start parsing the post data. In the "fieldtable" I have the name of the variable so I thought I'd just loop through again and pull all the data out of the returned arrays. But I couldn't figure out if there is any way to take a text field and somehow convert it to an array name.
Generated HTML:
<INPUT TYPE=CHECKBOX name="color[]" value=red>red
<INPUT TYPE=CHECKBOX name="color[]" value=blue>blue
Then when its posted,there will be an array $color[] that will contain "red" and/or "blue"..or nothing.
In my fieldtable, I can pull "color" out of it, but can I make this somehow reference the actual $color[] array?
Sorry this is so cofusing...I hope someone understands what I'm trying to do...
Thanks!
Mike
[SOLVED] reference to an array from a DB
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$color = (isset($_POST['color']) ? &$_POST['color'] : array() );