OK, so I've probably been staring at my screen too long today, but I'm really stuck on what I hope turns out to be a simple issue. Would be very grateful for advice.
SITUATION:
1. There's a form in the script that gets some information from a MySQL database, and using a WHILE loop it creates a list of names with checkboxes next to them.
2. Checkboxes, of course, have to be individually named, they can't share a common variable name.
3. I don't know in advance what the checkbox-able items will be or how many there will be, since they are generated on the fly from an ever-changing database. Thus, the variable names for the checkboxes are also generated on the fly, using a common prefix plus the information itself (short acronyms).
4. These unknown variables are passed to a part of the script that processes them and feeds them to a database table. I want to combine these commonly-prefixed variables into one long string as a new, single variable, which is the one that gets fed into a single field in another database table.
My initial thought was that I could use EREG to look for the variables with the common prefix, toss them into an array, and Bob's Your Uncle. Here's where we get to my problem.
I don't know what input-string to feed into EREG so it can do its check! It's a Catch-22 -- I can't identify the variables to feed until I can do something like EREG, and I can't do the EREG until, well, you get the idea.
Therefore I must be going about this the wrong way entirely. I've been banging my head against the wall trying to sort out how else I might accomplish the goal, but so far all I'm shaking loose is a bunch of brain farts.
I'm not sure I've explained this very well but if anyone has any idea what I'm on about and has any useful ideas...please help!
thanks!
brain...full...please...help...
Moderator: General Moderators
when parameters are passed from clients to the server they are transmitted as key=value-pairs (either via GET or POST).
One amazing thing about php is that it will treat those key=values pairs similar to php code.(assuming post-method) is similar to
-->
and now what you might be interested in-->
One amazing thing about php is that it will treat those key=values pairs similar to php code.
Code: Select all
<input type="hidden" name="key" value="value" />Code: Select all
$_POSTї'key'] = 'value';Code: Select all
<input type="hidden" name="keyї]" value="value1" />
<input type ="hidden" name="keyї]" value="value2" />Code: Select all
$_POSTї'key']ї] = 'value1';
$_POSTї'key']ї] = 'value2';Code: Select all
<input type="text" name="fieldsїname]"/>
<input type="text" name="fieldsїsurname]"/>Code: Select all
$_POSTї'fields']ї'name'] = ...;
$_POSTї'fields']ї'surname']=...;Hmmmmmmm...interesting. I'll have to play around with that until it sinks into my brain a little better.
The other thing I was thinking as I brooded on this overnight was that I could generate the variable names again in the processing-input-and-updating-database portion of the script, the same way I did in the form. Or sort of work backwards, creating them in that part of the script first and then using them in the form. Suppose that would work?
Well, I've got enough to play with to keep me occupied for a while at least...
Anyway, thanks very much for your usual spot-on advice! Much appreciated!
The other thing I was thinking as I brooded on this overnight was that I could generate the variable names again in the processing-input-and-updating-database portion of the script, the same way I did in the form. Or sort of work backwards, creating them in that part of the script first and then using them in the form. Suppose that would work?
Well, I've got enough to play with to keep me occupied for a while at least...
Anyway, thanks very much for your usual spot-on advice! Much appreciated!