how to show 6 randomly selected featured products?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have to show 6 of up to 1000 (most likely 200-600) featured products on
my online store.

My first thought was using this query:
$query = mysql_query("
   SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
pr.qty, pr.price, pr.sale_price, chp.cat_id
   FROM products as p
   LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
   LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
   ORDER BY RAND() LIMIT 6
 ");
but I needed 4 to 6 secunds to finish downloading the page.

Then I tried as a solution to grab all featured products from db, store
them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
actually just grab randomly 6 products form the array.
The home page is now much faster, of course, but I'm not sure how "smart"
is keep an array with 1000 elements in $_SESSION?

Thanks for any opinion!
:)

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux