I hope someone can help me as I am baffled. I have a script which sets up a number of check boxes for people to choose the fields of selected table which they wish to have in report. There are two hidden form variables to be passed to next script. One is the $table variable which comes from query string on previous page. The other is $sql variable, the value of which is generated by the selections made by user.
The problem is that no matter what I do I cant get the $sql value to be passed by the hidden form field. If I just echo the value to the screen by submitting form to self it appears ok so there is a value in the variable. I can even get it to appear in a query string.
Here is an example of my code.
function list_fields($table) {
$fields = mysql_list_fields('brahm001', $table);
$columns = mysql_num_fields($fields);
?><form method=post action="display_report.php" target="_blank"><?php
for ($i = 0; $i < $columns; $i++) { ?>
<input type="checkbox" name="<?php echo 'list'.$i; ?>" value="<?php echo mysql_field_name($fields, $i); ?>"><?php
echo mysql_field_name($fields, $i) . "\n<br />";
}
for ($i = 0; $i < $columns; $i++) {
$check="list".$i;
if($_POST[$check])
$sql = $sql.$_POST[$check].' , ';
}
$sql = substr($sql, 0, -2);
?>
<input type="hidden" name="sql" value="<?php echo $sql; ?>">
<input type="hidden" name="table" value="<?php echo $table; ?>">
<input type="submit" value="Generate Report">
</form>
[/COLOR]
This generates the check boxes for user to make selections. If I echo the value to the screen the value appears like retreat_id , booking_status , subheading2 or similar depending on what check boxes have been ticked.
The next page appears
$sql = $_POST['sql'];
echo $sql;
If I change the statements to read
$sql = $_POST['table'];
echo $sql;
the $table variable value is passed no problems.
If someone could tell me why the $sql value isn't being passed I would be most appreciative.
Thanks
Peter