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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:26:54+00:00 2026-05-20T18:26:54+00:00

I’m working an a script with product filters. Everything works fine but it’s too

  • 0

I’m working an a script with product filters. Everything works fine but it’s too slow. The reason is too much query’s. Query5 selects about 200 entrys. Query12 “search” in 130.000 entry’s.

Is it possible to make a mysql join or something faster of this with less query’s?

    <?php
                $query5 = mysql_query("SELECT id,fabrikant,naam FROM producten_new WHERE icecat_cat='".secure_in($obj->icecat)."'".$selecteren.""); 
                while($row5 = mysql_fetch_assoc($query5)){ 

                    foreach($_GET as $key=>$value){ 
                            if($key != "p" AND $key != "id" AND $key != "merk" AND $key != "submit" AND $value != "0"){ 

                                $query12 = mysql_query("SELECT COUNT(id) as aantal FROM producten_specs WHERE name='".secure_in(str_replace("_", " ", $key))."' AND value='".secure_in($value)."' AND product_id='".secure_in($row5['id'])."'"); 
                                $data12 = mysql_fetch_assoc($query12); 

                                if($data12['aantal']){ 
                                    $product_present = TRUE; 
                                } else { 
                                    $product_present = FALSE; 
                                    break;
                                } 

                            } 
                    }
                    if($product_present){
                        echo $row5['id']."<br />";
                        $product_present = FALSE;
                    }
               }
    ?>

Thanks.

EDIT:
Ok, fresh start. I hope its better (faster) this way:

        //Select products from category and brand
        $query5 = mysql_query("SELECT id FROM producten_new WHERE icecat_cat='".secure_in($obj->icecat)."'".$selecteren."");
        while($row5 = mysql_fetch_assoc($query5)){
            $query5_ids .= $row5['id'].", ";
        }
        //Remove last ','
        $query5_ids = substr($query5_ids, 0, -2);

        //Get all $_GET's
        foreach($_GET as $key=>$value){
            if($key != "p" AND $key != "id" AND $key != "merk" AND $key != "submit" AND $value != "0"){
                $specs_gets .= $key.",".$value.";";
                $count_gets++;
                $selection .= "name='".secure_in(str_replace("_", " ", $key))."' AND value='".secure_in($value)."' OR ";
            }
        }
        //Remove last ';'
        $specs_gets = substr($specs_gets, 0, -1);


        //$selection = " AND ".substr($selection, 0, -4);
        $selection = substr($selection, 0, -4);


        //THE query..
        //$query12 = mysql_query("SELECT product_id FROM producten_specs WHERE product_id IN ('".secure_in($query5_ids)."') ".$selection." ORDER BY product_id ASC");
        $query12 = mysql_query("SELECT product_id FROM producten_specs WHERE ".$selection." ORDER BY product_id ASC");
        while($row12 = mysql_fetch_assoc($query12)){

            if($product_hold == $row12['product_id']){
                $product_hold_count++;
            } else {
                $product_hold_count = FALSE;
                $product_hold = $row12['product_id'];
                $product_hold_count = 1;
            }

            if($product_hold_count == $count_gets){

                $query12_ids_ok .= $row12['product_id'].", ";
                $count_products++;
            }

        }
        //Remove last ','
        $query12_ids_ok = substr($query12_ids_ok, 0, -2);

EDIT2
Link to the website: snip

EDIT3
Some more information:

Example of the URL:

index.php
?p=categorie
&id=5
&brand=Asus
&Display_inch=0
&Resolution=0
&Buldin_camera=0
&Chipset=0
&Processor-speed=2400+MHz
&Processorfamilie=0
&Hard+disk-interface=0
&Total+capacitie=500+GB
*snip (because its very long)*
&submit=Submit+Filter

The database:

product_new (contains 3500 entrys) – Contains general product information

id, supplier, price, icecat_cat, name, etc.

1, Asus, 500, Notebook, K72F

product_specs (contains 130.000 entrys) – Contians product specifications

id, product_id, cat, name, value

1, 1, Processor, Processor-speed, 2400 Mhz

2, 1, Harddisk, Total-capacitie, 500 GB

EDIT4
I’m getting closer, see the code in my first edit, only product_id IN (‘”.secure_in($query5_ids).”‘) must be added into query12. Then I get the results I want and a lot faster! Anyone?

  • 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-05-20T18:26:55+00:00Added an answer on May 20, 2026 at 6:26 pm

    Got it!! Thanks for cooperate!

        //Producten selecteren uit categorie en merk 
        $query5 = mysql_query("SELECT id FROM producten_new WHERE icecat_cat='".secure_in($obj->icecat)."'".$selecteren.""); 
        while($row5 = mysql_fetch_assoc($query5)){ 
            $query5_ids .= $row5['id'].", "; 
        } 
        //Laatste , weg halen 
        $query5_ids = substr($query5_ids, 0, -2); 
    
        //Gets op een rijte zetten 
        foreach($_GET as $key=>$value){ 
            if($key != "p" AND $key != "id" AND $key != "merk" AND $key != "submit" AND $value != "0"){ 
                $specs_gets .= $key.",".$value.";"; 
                $aantal_gets++; 
                $uiteindelijk_selecteren .= "name='".secure_in(str_replace("_", " ", $key))."' AND value='".secure_in($value)."' OR "; 
            } 
        } 
        //Laatste ; weg halen 
        $specs_gets = substr($specs_gets, 0, -1); 
    
    
        //$uiteindelijk_selecteren = " AND ".substr($uiteindelijk_selecteren, 0, -4); 
        $uiteindelijk_selecteren = substr($uiteindelijk_selecteren, 0, -4); 
    
    
        //Overeenkomend met de get's selecteren 
        $query12 = mysql_query("SELECT product_id FROM producten_specs WHERE product_id IN (".secure_in($query5_ids).") AND ".$uiteindelijk_selecteren." ORDER BY product_id ASC");
        while($row12 = mysql_fetch_assoc($query12)){ 
    
            if($product_onthouden == $row12['product_id']){ 
                $product_onthouden_aantal++; 
            } else { 
                $product_onthouden_aantal = FALSE; 
                $product_onthouden = $row12['product_id']; 
                $product_onthouden_aantal = 1; 
            } 
    
            if($product_onthouden_aantal == $aantal_gets){ 
    
                $query12_ids_ok .= $row12['product_id'].", "; 
                $aantal_producten++; 
            } 
    
        } 
        //Laatste , weg halen 
        $query12_ids_ok = substr($query12_ids_ok, 0, -2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I

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.