Jump to content

[SOLVED] Something wrong in my SELECT DISTINCT Query


jaxdevil

Recommended Posts

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
}
?>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.