I seem to have sort of got this together, reading the mysql tables and entering them into the forms seem to be OK but I have a bit of a problem on returning the values of the variables.
(Brief form explanation: the form loads single line tables with a checkbox "called select1, select2, select3 etc depending on number of items in the table", type value also with hidden field "called type1, type2 etc" and item value also with a hidden field "called item1, item2 etc.)
The code below is what I am using to get the values from the form on submit.....
Code for getting the control values:
Code: Select all
<?php
if($theform=="cameras") {
$cb = 1;
$selectcb = "select"."$cb"; // Checkbox names cb + number
while ($cb <= $results) { // number of $results from query
if($selectcb) { // If checkbox selected
$typeentry = "$"."type"."$cb"; // **************************
$itementry = "$".item"."$cb"; // item value
$units = "$"."qt"."$cb"; // Quantity value
$CAMERALIST[$cb] = "$units"." $typeentry "." $itementry";
}
echo "$cb => $CAMERALIST[$cb] <br>"; // Test print checking
$cb++;
}
}
?>
Code for setting the control names in the form:
Code: Select all
<?php
while ($row = mysql_fetch_array($mysql_result)) { // ---------- OPEN WHILE
$num++;
if($list=="cameras") {
$type = $row["type"]; // the type from camera table
$item = $row["item"]; // the item from camera table
$qtname = "qt"."$num"; // the name for the quantity field
$selectname = "select"."$num"; // the name for checkbox
$qt = 1; // The default value for Quantity of items field
if($num==1) {
include "$path_tables"."inc_ord_table1.htm"; // LOAD IF 1 TABLE ONLY
}
if($num>0) {
include "$path_tables"."inc_ord_table2.htm"; // LOAD THE LAST TABLE
}
echo "<INPUT TYPE="HIDDEN" NAME="list" VALUE="$list">";
echo "<INPUT TYPE="HIDDEN" NAME="theform" VALUE="cameras">";
echo "<INPUT TYPE="HIDDEN" NAME="thetype" VALUE="$thetype">"; // Only for 35mm, 16mm and/or video types
}
?>
The problems are:
If I use the following to get the value of the variable called $typt1 the print out reads as $type1 which I expected but I didn't want this to print exactly as $type1 I expected iot to function as the variable $type1
Code: Select all
<?php
$typeentry = "$"."type"."$cb"; // **************************
?>
but if I change the line to:
Code: Select all
<?php
$typeentry = "$type1; // **************************
?>
I then get the value of the variable $type1 as I hoped, so as I don't know all the control names in advane as this is controled by the number of items in the table, how is it possible to write these variable so as they obtain the value as expected?
Another thing I have a problem with is the above code for Code for getting the control values is that the array seems to store an item for each control in the form and not just the values for the items of the checkbox, any ideas on what I am doing wrone here? I only want the values for the items checked.
It's late so I hope this is clear.