Hey everyone. I stumbled across something I thought I knew how to do, only to find that what I have tried is not working.

The challenege is to take a form, with a list element that allows multiple selection (selectfiles), and have the multiple selections added to an sql database. The table (filetopage) contains three columns, ID, pageid, fileid. There is an additional hidden form element that has the value of pageid as a 1, 2, 3, or 4.
Thus far I have tried the following:
Code: Select all
<?php
foreach ( $HTTP_POST_VARS['selectfiles'] as $filevalue ) {
$insertSQL = sprintf("INSERT INTO filetopage (page, file) VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS['pageid'], "int"),
GetSQLValueString($filevalue, "int"));
}
?>

My logic says when the form is submitted, this script will execute, inserting a new entry for each item that was selected in the list form.

Does anybody see the problem?
Thanks again!