I am dynamically creating a form with check boxes and hidden fields. The form
text names and hidden field names are being dynamically created depending on the button clicked on
my page (being pulled from my mysql database).
I am then needing to insert the responses to the check boxes into a users table.
my problem is:
(1) when a form check box name is dynamically generated... and that information is needing to be
passed to my script that runs the SQL to insert it into the database how do I assign the variable
names dynamically?
below is an example of the code that dynamically generates the form elements:
<?php
// roll through database and get competencies
while ($compdisplayarray = mysql_fetch_array($compdisplay)) {
$compdisplayarray1 = $compdisplayarray["Competency"];
$compdisplayarray2 = $compdisplayarray["Cluster_ID"];
$compdisplayarray3 = $compdisplayarray["Competency_ID"];
echo "<tr><td>".$compdisplayarray1 ."</td><td><select name=re".$compdisplayarray2.$compdisplayarray3
."><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>"
."<input type=hidden name=cl".$compdisplayarray2 ." value=".$compdisplayarray2 .">"
."<input type=hidden name=co".$compdisplayarray3 ." value=".$compdisplayarray3 ."> </td></tr>";
}
?>
after this is generated and answered by the user, they submit to a script that needs to run the following SQL:
INSERT INTO userscores (user, cluster_ID, competency_ID, score)
VALUES (this is where I need to use the varibles wich I do not know in advance);
I know this is possible and done quite often by developers but I am unsure how to aproach it. I know it more than likely
involves the $HTTP_POST_VARS function... but that is about as far as I have taken it.
Thanks in advance!
=================================
Imagination is more important than knowledge.
(A.E.)
text names and hidden field names are being dynamically created depending on the button clicked on
my page (being pulled from my mysql database).
I am then needing to insert the responses to the check boxes into a users table.
my problem is:
(1) when a form check box name is dynamically generated... and that information is needing to be
passed to my script that runs the SQL to insert it into the database how do I assign the variable
names dynamically?
below is an example of the code that dynamically generates the form elements:
<?php
// roll through database and get competencies
while ($compdisplayarray = mysql_fetch_array($compdisplay)) {
$compdisplayarray1 = $compdisplayarray["Competency"];
$compdisplayarray2 = $compdisplayarray["Cluster_ID"];
$compdisplayarray3 = $compdisplayarray["Competency_ID"];
echo "<tr><td>".$compdisplayarray1 ."</td><td><select name=re".$compdisplayarray2.$compdisplayarray3
."><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>"
."<input type=hidden name=cl".$compdisplayarray2 ." value=".$compdisplayarray2 .">"
."<input type=hidden name=co".$compdisplayarray3 ." value=".$compdisplayarray3 ."> </td></tr>";
}
?>
after this is generated and answered by the user, they submit to a script that needs to run the following SQL:
INSERT INTO userscores (user, cluster_ID, competency_ID, score)
VALUES (this is where I need to use the varibles wich I do not know in advance);
I know this is possible and done quite often by developers but I am unsure how to aproach it. I know it more than likely
involves the $HTTP_POST_VARS function... but that is about as far as I have taken it.
Thanks in advance!
Imagination is more important than knowledge.
(A.E.)