jaxdevil Posted June 21, 2008 Share Posted June 21, 2008 I don't know what is wrong, this is returning an empty set of rows, no results. I have used this many times before, this is just slightly modified, I don't know whats wrong. Do you see anything? <SELECT NAME="location" style="width:140px; border:0px solid; height:17px; padding:0px 3px; position:relative;"> <OPTION VALUE="NONE">-----Select Category----- <?php mysql_connect('localhost','xxx_xxx','xxxxxx'); mysql_select_db('xxx_xxx') or die(mysql_error()); $sql = "SELECT DISTINCT `subcat` FROM 'products'" or die(mysql_error()); $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { ?> <OPTION VALUE="<?=$row['subcat']?>"><?=$row['subcat']?> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/111275-solved-something-wrong-in-my-select-distinct-query/ Share on other sites More sharing options...
.josh Posted June 21, 2008 Share Posted June 21, 2008 perhaps put your die(..) on mysql_query instead of your $sql string assignment, see if it scream at you Link to comment https://forums.phpfreaks.com/topic/111275-solved-something-wrong-in-my-select-distinct-query/#findComment-571200 Share on other sites More sharing options...
jaxdevil Posted June 21, 2008 Author Share Posted June 21, 2008 I fixed it, here is the fix.... <SELECT NAME="location" style="width:180px; border:0px solid; height:17px; padding:0px 3px; position:relative;"> <OPTION VALUE="NONE">-----Select Category----- <?php mysql_connect('localhost','xxx_xxx','xxxxxx'); mysql_select_db('xxx_xxx') or die(mysql_error()); $sql_make = "SELECT DISTINCT `subcat` FROM products"; $query_make = mysql_query($sql_make); while($row = mysql_fetch_array($query_make)){ ?> <OPTION VALUE="<?=$row['subcat']?>"><?=$row['subcat']?> <? } ?> </SELECT> Link to comment https://forums.phpfreaks.com/topic/111275-solved-something-wrong-in-my-select-distinct-query/#findComment-571202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.