drmsolutions
Programmer
I have the following function to create a listbox which is used several times in my scripts for differnt listboxes:
My first instance of the listbox is for the user to select a title:
My question is how do I now update the value chosen by the user into the database?
I've tried:
But that just updates the database with "Array".
Any ideas?
Thanks in advance
Code:
function enhanced_list_box($options){
$sql = "select " . $options['id_field'];
$sql .= ", " . $options['value_field'];
$sql .= " from " . $options['table'];
$result = mysql_query($sql)
or die("error in SQL");
echo '<select name="'. $options['id_field']. '" size="1">';
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if($row[1] == $options['highlight_id']) {
echo '<option value="'. $row[0]. '" SELECTED>'.
$row[1]. '</option>';
} else {
echo '<option value="'. $row[0]. '">'.
$row[1]. '</option>';
}
}
echo '</select>';
}
My first instance of the listbox is for the user to select a title:
Code:
<? enhanced_list_box(array(
'table' => 'ctitle',
'id_field' => 'id',
'value_field' => 'title',
'highlight_id' => $Title));
?>
My question is how do I now update the value chosen by the user into the database?
I've tried:
Code:
"UPDATE customers SET "
." Title=\"".$_POST.$options['title'][1]."\"";
But that just updates the database with "Array".
Any ideas?
Thanks in advance