Jump to content

Why this SELECT DISTINCT function doesn't work ?


vanvoquan

Recommended Posts

I try to eliminate the duplicate values with Select Distinct but is doesn't work. Can anybody tell me why is not working. Any suggestion will be greatly appricitate. Here is the

[<td><?php
$datas=$_GET['keywords'];
$result=mysql_db_query($dbname,"SELECT products_id FROM products_description WHERE products_name LIKE'%$datas%'");
while($category1 = mysql_fetch_array($result))
{
$result2=mysql_db_query($dbname,"SELECT categories_id FROM products_to_categories WHERE products_id='". $category1['products_id'] ."'");
while($category2 = mysql_fetch_array($result2))
{
$result3=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category2['categories_id'] ."'");
while($category3 = mysql_fetch_array($result3))
{
$result5=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category3['parent_id'] ."'");
while($category4 = mysql_fetch_array($result5))
{
$result6=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category4['parent_id'] ."'");
while($category5 = mysql_fetch_array($result6))
{
$result7=mysql_db_query($dbname,"SELECT DISTINCT categories_description.categories_name, categories.categories_id, categories.parent_id FROM categories_description, categories WHERE  categories_description.categories_id = categories.categories_id AND categories.categories_id ='". $category5['parent_id'] ."'");
while($row = mysql_fetch_array($result7))
  {
  echo $row['categories_name'];
echo "<br>";
}
}
}
}
}
}
?></td>/code]

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.