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 8581229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:59:50+00:00 2026-06-11T20:59:50+00:00

Hi friends i have a custom search function in my website. Search is depending

  • 0

Hi friends i have a custom search function in my website. Search is depending on two tables such as,
product_table

CREATE TABLE `product_table` (
 `product_id` int(11) NOT NULL auto_increment,
 `product_name` varchar(100) NOT NULL,
 `country` varchar(200) NOT NULL,
 `added_time` timestamp NOT NULL default CURRENT_TIMESTAMP,
 PRIMARY KEY  (`product_id`));

multiple_table

CREATE TABLE `multiple_table` (
 `multi_id` int(11) NOT NULL auto_increment,
 `cat_id` int(11) NOT NULL,
 `product_id` int(11) NOT NULL,
 PRIMARY KEY  (`multi_id`));

I am giving option to users for search by one or more fields as product_name,country,cat_id,added_time

my search function as follows,

if(isset($_GET['s_button'])){
$sql2="SELECT a.product_id FROM product_table a, multiple_table b WHERE b.product_id= a.product_id ";
$where=array();
$values = array();
$types = '';
if(!empty($_GET['search_cat'])){
$search_cat=clean($_GET['search_cat']);
$where[]="AND cat_id='".$search_cat."'";
}
if(!empty($_GET['product_country'])){
$country=clean($_GET['product_country']);
$where[]="AND country='".$country."'";
}
if(!empty($_GET['model'])){
$keyword=clean($_GET['model']);
$where[]="AND product_name LIKE '%".$keyword."%'";
}
$sql2 .= implode($where). " ORDER BY a.product_id ";
}else{
$sql2 = "SELECT product_id FROM product_table ORDER BY Rand()";
}

But this makes some incorrect and huge number of results and also searching takes too much of time.I don’t know why is that.I have heard about MYSQL VIEWs does it make any sense for doing this? or do i have any easy way to make this happen? 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-11T20:59:51+00:00Added an answer on June 11, 2026 at 8:59 pm

    You should try like this:

    SELECT a.product_id FROM product_table a INNER JOIN multiple_table b ON b.product_id= a.product_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have a friends table with columns user1 and user2 and a users table
I have a table called 'friends', this contains the columns person1 and person2 .
I have a users table and a friends table. I want to get the
I have a table named friends with following structure: id, from_id, to_id, confirmed, ....
friends, i have a custom view class public class Zoom extends View { private
I have an custom class for an Core Data entity, called 'Friends'. As I
I am using django-friends and django-messages. I have modified my custom compose form to
Hai Freinds So far i have used this coding to create a custom Control
Hello friends I have tried many times but I am not successful than please

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.