Jump to content

Archived

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

deejay

i am getting multiple returns of identical searches even tho

Recommended Posts

I am using SELECT DISTINCT

 

any ideas on how I can get around this. If I cant do it in the mySQL query should I try and write some PHP to sort it?

 

<?php
$query =\"

SELECT DISTINCT

products.products_model,
product_pages.title,
products.products_id,
product_pages.products_id,
LEFT(product_pages.main_desc,300) AS description_one


FROM products,product_pages

WHERE product_pages.title LIKE \'%$search_keyword%\'
OR products.products_model LIKE \'%$search_keyword%\'

ORDER BY products.products_date_added OR product_pages.products_date_added

\"; 
?>

 

 

and the while code I am using to call up the rows of results is

 

<?php

while ($resultRow = mysql_fetch_assoc($searchResults))
         {    //open3
   // following if we decide which table the information is got from

   $title = $resultRow[\'title\'];
   $products_model = $resultRow[\'products_model\'];
   $main_desc = $resultRow[\'description_one\'];

   $descLength = strlen( $main_desc );

       if($descLength > 5){
           echo \'<tr bgcolor=\"#FFFFFF\">
           <td class=\"normal\">\'.$title.\' </td>
           <td height=\"30\" class=\"normal\">\'.$main_desc.\'</td>
           <td height=\"30\" class=\"normal\"><a href=\"products.php?title=\'.$title.\'\">Click Here</a></td>
           </tr>\'; }


        elseif($products_model){
           echo \'<tr bgcolor=\"#FFFFFF\">
           <td class=\"normal\">\'.$products_model.\' </td>
           <td height=\"30\" class=\"normal\">Shopping cart page for \'.$products_model.\' </td>
           <td height=\"30\" class=\"normal\"><a href=\"/catalog/product_info.php?products_id=\'.$resultRow[\'products_id\'].\'\">Click Here</a></td>
           </tr>\'; }

           else
             echo \'\';

           }     //end while
           echo \'</table>\';
           }   //close 2
?>

 

:( struggling with this code badly, does anyone know of a good mySQL book as I\'m finding the documentation heavy going.

 

Thanks for any help

Share this post


Link to post
Share on other sites

×

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.