Forum Moderators: coopster

Message Too Old, No Replies

Dynamic list has multiple entries

uncertain which MySQL command to use

         

Storyman

6:44 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



On an input form there is a dynamic drop down list to select from a dozen different categories. The form inserts correctly into the database.

The problem is that every time a category is selected the drop down menu list it an additional time. For example if the list has: apples, pears, oranges. If pears is selected the drop down list will display: apples, pears, pears, oranges.

I'm still learning how to set up inquiries and am not sure how to word it to display UNIQUE records (or even if UNIQUE is the correct command to use). I know there is a way, but not sure what it is.

Any help is appreciated.

Code for MySQL:
-------------------------------------------
SELECT subjects.subject_id, subjects.subject, quotes.quote_id, quotes.subject_pk, quotes.author, quotes.quote
FROM subjects LEFT JOIN quotes ON (subjects.subject_id = quotes.subject_pk)
ORDER BY subjects.subject ASC

Code for Dynamic Drop Down List:
-------------------------------------------
<select name="subject" id="subject">
<?php
do {
?>
<option value="<?php echo $row_rsQuotes['subject_id']?>"><?php echo $row_rsQuotes['subject']?></option>
<?php
} while ($row_rsQuotes = mysql_fetch_assoc($rsQuotes));
$rows = mysql_num_rows($rsQuotes);
if($rows > 0) {
mysql_data_seek($rsQuotes, 0);
$row_rsQuotes = mysql_fetch_assoc($rsQuotes);
}
?>
</select>

Storyman

7:07 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



Found the solution and chalking it up as one of those, "Duh!" moments.

The solution was simple. Since DW is the development software all that was needed was a second recordset for the subjects. The insert recordset script then links the subject_pk to the corresponding subject_id.