Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:43:37+00:00 2026-06-09T03:43:37+00:00

I am trying to query a mysql table using some likes. But it doesn’t

  • 0

I am trying to query a mysql table using some “likes”. But it doesn’t work at all.

This is my code:

 $color_base1 = $row[color_base1];
$color_base2 = $row[color_base2];

$result2 = mysql_query("SELECT * FROM item_descr WHERE (color_base1 LIKE 
           '%$color_base1%' OR color_base2 LIKE '%$color_base1%' OR color_base1 
           LIKE '%$color_base2%' OR color_base2 LIKE '%$color_base2%') 
           AND id_item != $itemId");

if (mysql_fetch_array($result2) == 0)
{
     $result2 = mysql_query("SELECT * FROM item_descr WHERE (keywords LIKE 
                '%$keywords%') AND id_item != $itemId LIMIT 3");
}
else 
{
    $row2 = mysql_fetch_array($result2);
    echo "<div class='similarTitle'>YOU MAY ALSO LIKE</div>";
    while ($row2 = mysql_fetch_array($result2))
    {
       echo "<div class='similarItems'>";
       echo "<img class='similarImage' src='images/{$row2[thumb1]}.jpg'>";
       echo "<div class='similarItemsText'>".$row2[name]."</div></div>";
    }
}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:43:38+00:00Added an answer on June 9, 2026 at 3:43 am

    try changing your queries into these:

    Query1:

    SELECT  * 
    FROM    item_descr 
    WHERE   (color_base1 LIKE CONCAT('%' , $color_base1, '%') OR 
             color_base2 LIKE CONCAT('%' , $color_base1, '%') OR 
             color_base1 LIKE CONCAT('%' , $color_base2, '%') OR 
             color_base2 LIKE CONCAT('%' , $color_base2, '%')) AND 
             id_item != $itemId
    

    Query 2:

    SELECT  * 
    FROM    item_descr 
    WHERE   keywords LIKE CONCAT('%' , $keywords, '%') AND 
            id_item != $itemId 
    LIMIT 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to query a MySQL database using an array but I'm having trouble!
I'm trying to optimize this mysql query using EXPLAIN. Can somebody please help me
I'm trying to query a mysql table which places its date in the following
I am trying to use some parameters in my sql query like this; Answer_table
I have folowing MYsql Query And Trying to right outer join but unable to
i'm trying the following MySQL query to fetch some data: SELECT m.*, t.* FROM
I'm using Zend_Db to query a table. I have some WHERE clauses that need
i was triyng for some days a way to do this using only MySQL
I've trying to create some stats for my table but it has over 3
I'm trying to insert some japanese words in a mysql table! If I insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.