每個頁面都列出了特定零售商可用的所有優惠券。我在數據庫中查詢標題中的所有優惠券代碼,因爲我計算返回的行數,並在頁面元標題中使用該信息。我現在也想顯示陣列中前2個優惠券的標題。我將如何去解壓數組中的前2個結果而不再查詢數據庫?如何從mysql數組中檢索前2個結果而不再查詢?
這是我到目前爲止有:
$retailer_coupons = "select C.couponid,C.fmtc_couponid,C.merchantid,C.exclusive,C.label,C.shoppingtip,C.restrictions,C.coupon,C.custom_order,C.link,C.image,C.expire,C.unknown,M.name,M.approved,M.homepageurl,M.category from tblCoupons C,tblMerchants M where C.merchantid=M.merchantid and C.begin < ".mktime()." and C.expire > ".mktime()." and C.merchantid=".$merchantid." and M.display='1' and C.user_submitted='' order by C.custom_order desc, C.coupon desc";
$retailer_coupons_result = mysql_query($retailer_coupons) or die(mysql_error());
$count_coupons=mysql_num_rows($retailer_coupons_result);
$meta_title = ''.$name.' Coupon Codes ('.$count_coupons.' coupons available)';
['或死亡()'必須死](http://www.phpfreaks.com/blog/or-die-must-die)。另外,你是什麼意思*再次查詢數據庫*?你還沒有取得任何結果。 – Phil