Jump to content

Using LIKE statement but excluding rows


melting_dog

Recommended Posts

Hi all,

 

I have a site that displays a product, then shows similar products based off the name of the first (like a 'You might also like...' list). However the original product keeps appearing in this similar product list. I need a way to exclude that product.

 

You can see this here:

 

http://adamsherman.com.au/postureperfection/product-page/?prodid=3

 

Notice how the Reno Stool also appears in the suggested items list.

 

Can anyone help me out? Heres the SQL:

 

$sql = "SELECT * FROM product WHERE " . implode(' OR ', $searchTerms) . " AND product_id != '$prodid' LIMIT 3";

 

The .implode() just splits up the name of the item whilst $prodid is the items unique identifier. I have also tried NOT LIKE, <> and != $productname as well.

 

Any help would be much appreciated. Thanks!

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.