I've got a bit of a sticky problem.
I have created a feedback form which links into an XML file to get its values, and uses PHP's built in XML support.
In future, the XML file will be kept up-to-date by the user, who will add more reports as the need arises.
Therefore, I can never know how many reports there will be.
So to deal with this, the code steps through the XML file, and creates a checkbox and a number of associated radio buttons for each entry it finds (resulting in the example below).
This is so the user can tick the reports they have used, and give them a usefulness rating (only two 'usefulness' values shown here for clarity).
<!-- Report 1 - $id="report1"-->
<INPUT TYPE="CHECKBOX" NAME="Report[]" VALUE="<?=$id;?>">
<INPUT TYPE="RADIO" NAME="<?=id;?>usefulness[]" VALUE="1">
<INPUT TYPE="RADIO" NAME="<?=id;?>usefulness[]" VALUE="2">
<!-- Report 2 - $id="report2"-->
<INPUT TYPE="CHECKBOX" NAME="Report[]" VALUE="<?=$id;?>">
<INPUT TYPE="RADIO" NAME="<?=id;?>usefulness[]" VALUE="1">
<INPUT TYPE="RADIO" NAME="<?=id;?>usefulness[]" VALUE="2">
I know I can get these values using HTTP-POST_VARS when I have posted the form, using the following code:
// Find the number of 'Report' checkboxes which have been ticked
$numfields = count($HTTP_POST_VARS["Report"]);
// Create a variable $report for each 'report' found and pass the checkbox value into it.
for ($i = 0; $i < $numfields; $i++) {
$report = "Report: " . $HTTP_POST_VARS["Report"][$i];
print $report;
}
I get this result, which is fine:
Number of fields = 2
Report: report1
Report: report2
The problem is, I need store each of the checkbox values in a different variable ($report), so I can pick the data up and put it into a database record.
But I don't know how to make it create a new variable for each checkbox value it finds.
Please excuse me if I am being thick, but I've been on this project for a while, and I'm having serious brainfade with it!
Hope this all makes sense!!
Can anyone help?