I've got a couple of questions about select lists on an existing database that I'm hoping someone can help me with:
1. I'd like to do a select list for a Month field entry. The basic code is not the problem; it's my existing fields that are the challenge. How do I make the select list add "selected='selected'" to the correct option when I'm editing records since my existing fields (2,000+) are written out longhand. I think I could do it if I just knew the variable that contains the field value.
2. In another area of the form, I have a categories field. I'd like to have the option of selecting from an existing select list, or adding/editing a category myself. I know how to code it either way, but not how to have both options on a single form. (It seems to ignore both of them when I do that.) Here's the code I'm using:
or
1. I'd like to do a select list for a Month field entry. The basic code is not the problem; it's my existing fields that are the challenge. How do I make the select list add "selected='selected'" to the correct option when I'm editing records since my existing fields (2,000+) are written out longhand. I think I could do it if I just knew the variable that contains the field value.
2. In another area of the form, I have a categories field. I'd like to have the option of selecting from an existing select list, or adding/editing a category myself. I know how to code it either way, but not how to have both options on a single form. (It seems to ignore both of them when I do that.) Here's the code I'm using:
<td>Section:</td><td><input type="text" name="section" value=""></td>
or
<td>Section:</td><td>
<select name="section">
<?php
$database->setQuery( "SELECT DISTINCT section FROM table_name ORDER BY section ASC" );
$sections = $database->loadObjectList();
foreach($sections as $section){
?>
<option value="<?php echo $section->section; ?>"><?php echo $section->section; ?></option>
<?php } ?>
</select>
</td>