Ok, here is some code.
Thanks for looking!
The first snippet is from an include file I have...I simply call the function whereever I would like a listbox.
<?php
function create_dropdown( $select_name, $table, $id_field, $value_field, $highlight_id){
create_list_box( array ( 'select_tag_name' => $select_name,
'table' => $table,
'id_field' => $id_field,
'value_field' => $value_field,
'highlight_id' => $highlight_id )
);
}
//
function create_list_box($options){
$sql = "select " . $options['id_field'];
$sql .= ", " . $options['value_field'];
$sql .= " from " . $options['table'];
// add where clause
if(isset($options['where_statement'])) {
$sql .= " where " . $options['where_statement'] ;
}
// add order-by clause
// $sql .= " order by " . $options['value_field'];
$result = mysql_query($sql) or die ("Could Not Find Database");
// create select tag
echo '<select class=\'select\' name="', $options['select_tag_name'], '" size="1">';
// assign selected value
//if($options['table'] == ' '){
// echo '<option value=\' \' SELECTED> </option>';
//}
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ if($row[0] == $options['highlight_id']) {
echo '<option value="', $row[1], '">',$row[1], '</option>';
//$options['highlight_id'] == $row[0];
} else {
echo '<option value="', $row[0], '">',$row[1], '</option>';
}// end if/else
}// end while
echo '</select>';
}
?>
This second snippet is the listbox that is
built:
<select class='select'
name="category" size="1"><option value="1">cat 1</option><option value="2">cat 2</option><option value="3">cat 3</option><option value="4">all</option></select>
I need the selected value from this
list sent, with the other form-variables of the same form,
to the script that the form calls.
Thanks again!