Jump to content


Photo

i am getting multiple returns of identical searches even tho


  • Please log in to reply
No replies to this topic

#1 deejay

deejay
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBournemouth, UK

Posted 14 April 2003 - 01:21 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users