kayne31 Posted January 25, 2010 Share Posted January 25, 2010 Hello, I am new to the forums scene so I appoligise if what I post is incorrect or in the wrong place but I hope someone can help me. I am busy with creating a catalog page for a friend and I have created a drop down menu to select the product from I am filling this menu as follows: <option value="<?php echo $row_Recordset1['Make']?>"><?php echo $row_Recordset1['Make']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> However this is only giving me all the values from make but I only want to display unique values How can I do this? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/189708-display-unique-values-in-a-drop-down-menu/ Share on other sites More sharing options...
jl5501 Posted January 25, 2010 Share Posted January 25, 2010 You do not show your query to generate your record set, but if you have select distinct at the start, it will only show unique values. Link to comment https://forums.phpfreaks.com/topic/189708-display-unique-values-in-a-drop-down-menu/#findComment-1001196 Share on other sites More sharing options...
kayne31 Posted January 25, 2010 Author Share Posted January 25, 2010 Hi, See said I was new to this sort of thing is this what you needed to see? mysql_select_db($database_*, $*); $query_Recordset1 = "SELECT Make FROM Products ORDER BY Make ASC"; $Recordset1 = mysql_query($query_Recordset1, $*) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); Link to comment https://forums.phpfreaks.com/topic/189708-display-unique-values-in-a-drop-down-menu/#findComment-1001198 Share on other sites More sharing options...
manwhoeatsrats Posted January 25, 2010 Share Posted January 25, 2010 Make it so your Query is "SELECT DISTINCT" instead of SELECT. "SELECT DISTINCT" will make it so it will only pull a value type once. Link to comment https://forums.phpfreaks.com/topic/189708-display-unique-values-in-a-drop-down-menu/#findComment-1001200 Share on other sites More sharing options...
kayne31 Posted January 25, 2010 Author Share Posted January 25, 2010 Thank you all very much now works just the way I want ti to :D :D Link to comment https://forums.phpfreaks.com/topic/189708-display-unique-values-in-a-drop-down-menu/#findComment-1001202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.