Codice PHP:
[COLOR=royalblue]if ($query_product != "no") { $query_limit_product = sprintf("%s LIMIT %d, %d", $query_product, noquote_smart($startRow_product), noquote_smart($maxRows_product)); $product = mysql_query($query_limit_product, $databaseConnect) or die(mysql_error()); $row_product = mysql_fetch_assoc($product); $all_product = mysql_query($query_product); $totalRows_product = mysql_num_rows($all_product); $totalPages_product = ceil($totalRows_product/$maxRows_product)-1; $queryString_product = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_product") == false && stristr($param, "totalRows_product") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_product = "&" . htmlentities(implode("&", $newParams)); } } $queryString_product = sprintf("%s", $queryString_product); }[/COLOR]
Codice PHP:
[COLOR=royalblue] // output search results if ($indcount == 0) { $sql = "SELECT prodCategory, ( (1.3 * (MATCH(prodName) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) + (0.6 * (MATCH(prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) ) AS relevance FROM affiliSt_products1 WHERE ( MATCH(prodName,prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE) ) HAVING relevance > 0 ORDER BY prodCategory ASC"; } else { $sql = "SELECT prodCategory, MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") AS relevance FROM affiliSt_products1 WHERE MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") HAVING relevance > 0 ORDER BY prodCategory ASC"; } $getRefineCategory = mysql_query($sql, $databaseConnect) or die(mysql_error()); $refineCategory = mysql_fetch_assoc($getRefineCategory); $storedCategory = ''; $count = 0; do { $refcatresult = ucwords(strtolower($refineCategory['prodCategory'])); if ($storedCategory != $refcatresult && $refcatresult != NULL) { if (isset($_GET['rshow'])) { $rshow = '&rshow=all'; } else { $rshow = ''; } $box_content->assign("REFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).'&pscat='.str_replace(" ", "+", $refcatresult).$rshow); $box_content->assign("REFINE",$refcatresult); $box_content->parse("prod.refine.li"); if ($count >= 3 && !isset($_GET['rshow'])) { $box_content->assign("REFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).'&rshow=all'); $box_content->assign("REFINE",'Altre categorie...'); $box_content->parse("prod.refine.li"); break; } $storedCategory = $refcatresult; } else { $refcatresult = ucwords(strtolower($refineCategory['prodCategory'])); } $count++; } while ($refineCategory = mysql_fetch_assoc($getRefineCategory)); // get keywords $pieces = explode(" ", strip_tags($_GET['ps'])); $kp = count($pieces); // reset pieces $pluspieces = ''; for ($pi=0;$pi<$kp;$pi++) { $pluspieces .= $pieces[$pi].' '; } $pluspieces = rtrim($pluspieces, " "); // change refine prices inaccordance with selected refine category $extracondition = ''; if (isset($_GET['pscat'])){ $extracondition .= " AND prodCategory = ".quote_smart($_GET['pscat']).""; } // output search results if ($indcount == 0) { $sql = "SELECT prodPrice, ( (1.3 * (MATCH(prodName) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) + (0.6 * (MATCH(prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) ) AS relevance FROM affiliSt_products1 WHERE ( MATCH(prodName,prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE) ) $extracondition HAVING relevance > 0 ORDER BY prodPrice DESC LIMIT 0,1"; } else { $sql = "SELECT prodPrice, MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") AS relevance FROM affiliSt_products1 WHERE MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") $extracondition HAVING relevance > 0 ORDER BY prodPrice DESC LIMIT 0,1"; } $getRefinePrice = mysql_query($sql, $databaseConnect) or die(mysql_error()); $refinePrice = mysql_fetch_assoc($getRefinePrice); $highprice = $refinePrice['prodPrice']; if ($indcount == 0) { $sql = "SELECT prodPrice, ( (1.3 * (MATCH(prodName) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) + (0.6 * (MATCH(prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE))) ) AS relevance FROM affiliSt_products1 WHERE ( MATCH(prodName,prodDescription,merchant,prodCategory,prodBrand) AGAINST (".quote_smart($pluspieces)." IN BOOLEAN MODE) ) $extracondition HAVING relevance > 0 ORDER BY prodPrice ASC LIMIT 0,1"; } else { $sql = "SELECT prodPrice, MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") AS relevance FROM affiliSt_products1 WHERE MATCH (prodName,prodDescription,prodBrand,prodCategory) AGAINST (".quote_smart($pluspieces).") $extracondition HAVING relevance > 0 ORDER BY prodPrice ASC LIMIT 0,1"; } $getRefineLowPrice = mysql_query($sql, $databaseConnect) or die(mysql_error()); $refineLowPrice = mysql_fetch_assoc($getRefineLowPrice); $lowprice = $refineLowPrice['prodPrice']; if (($lowprice + 50.00) < $highprice) { $divideprice = ($highprice - $lowprice) / 5; if (isset($_GET['pscat'])) { $pscatvar = '&pscat='.str_replace(" ", "+", $_GET['pscat']); } else { $pscatvar = ''; } if (isset($_GET['rshow'])) { $rshow = '&rshow=all'; } else { $rshow = ''; } $box_content->assign("PRICEREFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).$pscatvar.'&pslow='.$lowprice.'&pshigh='.ceil($lowprice + $divideprice).$rshow); $box_content->assign("PRICEREFINE",$row_product['prodCurrency'].$lowprice.' - '.$row_product['prodCurrency'].ceil($lowprice + $divideprice)); $box_content->parse("prod.refine.priceli"); $box_content->assign("PRICEREFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).$pscatvar.'&pslow='.ceil($lowprice + $divideprice).'&pshigh='.ceil($lowprice + ($divideprice * 2)).$rshow); $box_content->assign("PRICEREFINE",$row_product['prodCurrency'].ceil($lowprice + $divideprice).' - '.$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 2))); $box_content->parse("prod.refine.priceli"); $box_content->assign("PRICEREFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).$pscatvar.'&pslow='.ceil($lowprice + ($divideprice * 2)).'&pshigh='.ceil($lowprice + ($divideprice * 3)).$rshow); $box_content->assign("PRICEREFINE",$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 2)).' - '.$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 3))); $box_content->parse("prod.refine.priceli"); $box_content->assign("PRICEREFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).$pscatvar.'&pslow='.ceil($lowprice + ($divideprice * 3)).'&pshigh='.ceil($lowprice + ($divideprice * 4)).$rshow); $box_content->assign("PRICEREFINE",$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 3)).' - '.$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 4))); $box_content->parse("prod.refine.priceli"); $box_content->assign("PRICEREFLINKDATA",$installDir['value'].'index.php?case=search&ps='.str_replace(" ", "+", strip_tags($_GET['ps'])).$pscatvar.'&pslow='.ceil($lowprice + ($divideprice * 4)).'&pshigh='.ceil($lowprice + ($divideprice * 5)).$rshow); $box_content->assign("PRICEREFINE",$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 4)).' - '.$row_product['prodCurrency'].ceil($lowprice + ($divideprice * 5))); $box_content->parse("prod.refine.priceli"); } $box_content->parse("prod.refine"); } [/COLOR]