circus.fire Posted July 22, 2009 Share Posted July 22, 2009 Hello all-I am very new to this so here it goes... I am using the code below to populate a drop-down list. Problem is that the table it's pulling from has duplicates, any idea how to get these duplicates to not show up in the list? The DB is currently in Access and I am trying to move it over-so it's already populated. Thanks! function dept_cnumDropDown(){ echo '<select name="Dept_CourseNumber" id="Dept_CnumBox";>'; $result = db_query("SELECT Dept_Cnum FROM coursepack_info ORDER BY Dept_Cnum ASC"); if(db_num_rows($result)) { while ($row = db_fetch_array($result)) { echo '<option value="'.$row['Dept_Cnum'].'" class="drop_down">'.$row['Dept_Cnum'].'</option>'; } } else { echo "<option value=''>There are no Department/Course Numbers currently listed</option>"; } echo '</select>'; } if(!empty($_REQUEST['btnSubmit'])) { echo 'they hit the button'; } ?> Link to comment https://forums.phpfreaks.com/topic/167005-php-driven-drop-down-box/ Share on other sites More sharing options...
bruce080 Posted July 22, 2009 Share Posted July 22, 2009 $result = db_query("SELECT Dept_Cnum FROM coursepack_info ORDER BY Dept_Cnum ASC"); Try the following query: $result = db_query("SELECT DISTINCT Dept_Cnum FROM coursepack_info ORDER BY Dept_Cnum ASC"); EDIT: Now that I read your post, I'm not sure what your asking. Could you possibly post an example from you Database? Link to comment https://forums.phpfreaks.com/topic/167005-php-driven-drop-down-box/#findComment-880584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.