Hey all, hope someone can offer a little bit of help and advice. I am trying to use a program called WebCalendar and it allows for adding events to a calendar.. pretty simple.. When a user clicks on a date, they open up a form and in this form can put in information for an event that gets logged on that date.
With the program came a way to add an array that allowed for making a new form field. One of those was a selectlist where one should be able to select multiple items from that list that get logged. (ie room reservations.) The list displays just fine, but even when multiple items are selected, only one shows up(or is even stored in the mysql database).
A couple chunks of code effect that.. in an extras file is:
$site_extras = array (
array (
"RoomName", // unique name of this extra field (used in db)
"Room Name", // how this field will be described to users
$EXTRA_SELECTLIST, // type of field
// List of options (first will be default)
array ( "None", "room1", "room11", "room12", "room13" ),
0 // arg 2 (unused)
)
);
In an entry file that controls the display from the above array is:
} else if ( $extra_type == $EXTRA_SELECTLIST ) {
// show custom select list.
echo "<SELECT NAME=\"" . $extra_name . "\" MULTIPLE>";
if ( is_array ( $extra_arg1 ) ) {
for ( $j = 0; $j < count ( $extra_arg1 ); $j++ ) {
echo "<OPTION";
if ( ! empty ( $extras[$extra_name]['cal_data'] ) &&
$extra_arg1[$j] == $extras[$extra_name]['cal_data'] )
echo " SELECTED";
echo " >" . $extra_arg1[$j] . "</OPTION>\n";
}
}
echo "</SELECT>";
}
And lastly in a backend functionality file is an IF statement that has this in it for its control:
$extra_type == $EXTRA_SELECTLIST) {
$sql = "INSERT INTO webcal_site_extras " .
"( cal_id, cal_name, cal_type, cal_data ) VALUES ( " .
"$id, '$extra_name', $extra_type, '$value' )";
Can anyone see why only one selected item is being inserted into the DB and not the multiple items that can be selected? Thanks so much for the help!