0) { $sid = $_REQUEST['sid']; $theMerchant = new Merchant(3, $sid); if(!$theMerchant->isPaidValidMerchant() && !isMerchantAdmin()) { header("Location: /bikeshops/promotions.php"); } $shop = new Shop($sid); // for merchant header } $countrycode = getCountryCodeSelected(); $keyword=''; $e_keyword=''; if($_REQUEST['keyword'] != "") { $keyword = $_REQUEST['keyword']; $e_keyword = mysql_escape($_REQUEST['keyword']); } // begin assembling query. Join 4 tables. $sql = "SELECT DISTINCT * FROM merchants AS M, merchant_news AS N, bikeshops_sg AS BS WHERE M.merchantid = N.merchantid AND M.shopid = BS.sid and paystartdate < NOW() and payenddate > NOW() AND BS.country = '$countrycode' AND M.merchantid <> 235"; if ((int)$sid > 0) $sql = $sql . " AND BS.sid='" . $sid . "'"; if ($e_keyword != "") $sql = $sql . " AND (N.title LIKE '%" . $e_keyword ."%' OR N.content LIKE '%". $e_keyword ."%')"; if ($sortid == "1") { $sql .= " ORDER BY N.datecreated"; } else if ($sortid == "2") { $sql .= " ORDER BY BS.shopname"; } else if ($sortid == "3") { $sql .= " ORDER BY RAND()"; } else { $sql .= " ORDER BY N.datecreated"; } if ($order == "D") { $sql = $sql . " DESC"; } else if ($order == "A") { $sql = $sql . " ASC"; } else { $sql = $sql . " DESC"; } //pages definitions $NO_OF_ITM_PER_PAGE = 10; $NO_OF_PGS_PER_SHEET = 10; $COLS = 1; $ROWS = 10; //image size definitions $PWIDTH = 120; $PHEIGHT = 160; //page sanity check if ((!$page_id) || $page_id < 1 ) $page_id=1; //calculate pages $limit = $NO_OF_ITM_PER_PAGE; $sql_nrows = "SELECT DISTINCT COUNT(*) FROM merchants as M, merchant_news as N, bikeshops_sg AS BS WHERE M.merchantid = N.merchantid AND M.shopid = BS.sid and paystartdate < NOW() and payenddate > NOW() AND BS.country = '$countrycode'"; if ($sid > 0) $sql_nrows = $sql_nrows . " AND BS.sid='" . $sid . "'"; if ($e_keyword != "") $sql_nrows = $sql_nrows . " AND (N.title LIKE '%" . $e_keyword ."%' OR N.content LIKE '%". $e_keyword ."%')"; $r_nrows = mysql_query($sql_nrows, $link); $row_nrows = mysql_fetch_row($r_nrows); $no_of_rows = $row_nrows[0]; $no_of_pages = $no_of_rows/$limit; $no_of_pages = ceil($no_of_pages); //page sanity check if ($page_id > $no_of_pages) $page_id = $no_of_pages; $offset=$limit*($page_id-1); //10 pages per sheet $sno = ceil($page_id/$NO_OF_PGS_PER_SHEET); //calculate total no. of sheets $no_of_sheets = ceil($no_of_pages/$NO_OF_PGS_PER_SHEET); $sql = $sql . " LIMIT $offset, $limit"; //add pageviews and reset resource pointer to front //echo($sql); exit; $r = mysql_query($sql); if($r) { if (mysql_num_rows($r) > 0) { while($row_news = mysql_fetch_array($r)) { mysql_query("UPDATE merchant_news SET views = views + 1 WHERE nid = '".$row_news["nid"]."'"); } if (!mysql_data_seek($r,0)) { $r = mysql_query($sql); } } } //define vars $toggle = 0; $sn = (($page_id-1) * $NO_OF_ITM_PER_PAGE) + 1; //assemble GET string $getstr = ""; if ($sortid) { $getstr = $getstr . urlencode("&sortid=") . urlencode($sortid);} if ($order) { $getstr = $getstr . urlencode("&order=") . urlencode($order);} if ($sid) { $getstr = $getstr . urlencode("&sid=") . urlencode($sid);} //plain unencoded string for links $getpstr = ""; if ($sortid) { $getpstr = $getpstr . "&sortid=" . urlencode($sortid);} if ($order) { $getpstr = $getpstr . "&order=" . urlencode($order);} if ($sid) { $getpstr = $getpstr . "&sid=" . urlencode($sid);} if($subdomain == 'my') { $WEBPAGE_TITLE = $sid > 0 ? $shop->getShopname() . ' Promotions Malaysia | Togoparts.com' : 'Togoparts.com - Malaysia Bike Shop Promotions and News'; $meta_description = "Check out promotions from Bikeshops across Malaysia."; $fb_img = 'togoparts-my-square-logo.jpg'; } else { $WEBPAGE_TITLE = $sid > 0 ? $shop->getShopname() . ' Promotions Singapore | Togoparts.com' : 'Togoparts.com - Singapore Bike Shop Promotions and News'; $meta_description = "Check out promotions from Bikeshops across Singapore."; $fb_img = 'togoparts-square-logo.jpg'; } ?>

Latest