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]

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.