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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.