View Single Post
  #25  
Old 01-17-2003, 12:34 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

okay - sorry..amateur mistake

amend the code to:

Code:
<? // give it all available products to work with $products_id = func_query("SELECT productid FROM $sql_tbl[products] WHERE forsale='Y' and avail>0"); // set the variables $str = ""; $numberRandoms=10; // set this to how many you want to show // the witchcraft $query_condition = " AND ("; srand((double)microtime()*1000000); $rnd = rand(0, count($products_id)-1); $query_condition .= "$sql_tbl[products].productid='".$products_id[$rnd][productid]."'"; for($i = 0; $i < $numberRandoms - 1; $i++) { $rnd = rand(0, count($products_id)-1); if (!ereg("'".$products_id[$rnd][productid]."'", $query_condition)) { $query_condition .= " OR $sql_tbl[products].productid='".$products_id[$rnd][productid]."'"; } } // finish off the query $query_condition .= ")"; // runs the new random query against the database // $query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND avail>0".$query_condition; $query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid".$query_condition; // give the product array to smarty to make it available sitewide. $randoms = func_query($query); $smarty->assign("randoms",$randoms); ?>
__________________
ex x-cart guru
Reply With Quote