twilitegxa Posted January 30, 2010 Share Posted January 30, 2010 I have this code for a select option list: <?php $get_map = "select * from monsters1"; $get_map_res = mysql_query($get_map, $conn) or die(mysql_error()); echo "<select name=\"maps\" onchange=\"showMap(this.value)\"> <option selected=\"selected\">None Selected</option>"; while ($list_maps = mysql_fetch_array($get_map_res)) { $map_id = $list_maps['id']; $map = $list_maps['map']; echo "<option value=\"$map_id\">$map</option>"; } echo "</select>"; ?> But I have several records with the same value. How can I make it to where each value only displays once in my list? Link to comment https://forums.phpfreaks.com/topic/190336-select-option-list-help-multiple-values-are-the-same/ Share on other sites More sharing options...
mmarif4u Posted January 30, 2010 Share Posted January 30, 2010 You can use group by for that field. $get_map = "select * from monsters1 group by map"; You can change map to the field, which you want to show once. Link to comment https://forums.phpfreaks.com/topic/190336-select-option-list-help-multiple-values-are-the-same/#findComment-1004149 Share on other sites More sharing options...
twilitegxa Posted January 30, 2010 Author Share Posted January 30, 2010 Oh, thank you so much! I knew it was something simple, I just couldn't remember what it was. Thanks so much! Link to comment https://forums.phpfreaks.com/topic/190336-select-option-list-help-multiple-values-are-the-same/#findComment-1004329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.