0) { while($ZipArr=mysql_fetch_array($SipRes)) { $RID=$ZipArr['intId']; if($num == $i) $sep=""; else $sep=","; $ZipId.=$RID.$sep; $i=$i+1; } } } if($ZipId != "") { $ZIP_ID = " and coupon.MerchantId in ($ZipId)"; $set_val="Set"; } else if($cusinetype != "" ) { $CUS_Id=""; $SELRES="select * from tb_restaruntinfo where intCusineId = '$cusinetype'"; $RES_REST=mysql_query($SELRES) or die(mysql_error()); while($ResARR=mysql_fetch_Array($RES_REST)) { $CUS_Id=$ResARR['MerchantId']; $CUS_Id.=","; } $CUS_Id1=trim($CUS_Id,","); if($CUS_Id1 != "") { $CUSINE=" and coupon.MerchantId in ($CUS_Id1)"; $set_val="Set"; } else $set_val = "Null"; } else $set_val = "Null"; } if($_GET['resid'] != "") { $pagqry="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.MerchantId = '".$_GET['resid']."' and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc "; $pagres="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.MerchantId = '".$_GET['resid']."' and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc limit $start1, $coupon_per_page "; } else { if($set_val == "Set") { $pagqry="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' ".$ZIP_ID.$CUSINE." and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc "; $pagres="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' ".$ZIP_ID.$CUSINE." and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc limit $start1, $coupon_per_page "; } else if($set_val == "Null") { $pagqry="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.CouponStatus = 'InActive' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc "; $pagres="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.CouponStatus = 'InActive' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc limit $start1, $coupon_per_page "; } else { $pagqry="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc "; $pagres="select * from tb_coupon coupon,tb_order orders where coupon.dtStDate <= '$dt' and coupon.dtEndDate >= '$dt' and coupon.CouponStatus = 'Active' and coupon.intCouponId = orders.CouponId GROUP BY coupon.MerchantId order by orders.intOrderNo asc limit $start1, $coupon_per_page "; } } if($zipcode != "") { $res1=" in the Zipcode '".$zipcode."'"; } else if($resname != "") { $res1=" in the name '".$resname."'"; } else if($state != "") { foreach($statearray as $statekey => $statevalue){ if($statekey == $state) $st=$statevalue; } $res1.=" in the State '".$st."'"; ############### Find City if($city != "") { $cityquery1="select * from ".CITY." where intCityId ='".$city."' "; $cityresult1=mysql_query($cityquery1); $cityarr1=mysql_fetch_array($cityresult1); $cityname1=$cityarr1['varCityName']; $res1.=" and the city '".$cityname1."'"; } } else if($cusinetype != ""){ $cusineQuery1="select varCusine from ".CUSINE." where intCusineId = '".$cusinetype."' "; $cusineResult1=mysql_query($cusineQuery1); $cusineArray1 = mysql_fetch_array($cusineResult1); $cusine_type = $cusineArray1['varCusine']; $res1=" in the cuisine type '".$cusine_type."'"; //if($val != "") //$res.=" and Restaurant name begins with '".$val."'"; } //print $pagqry; $pag_res = mysql_query($pagqry); $total_records = mysql_num_rows($pag_res); $pages = ceil($total_records / $coupon_per_page); $CouponRes = mysql_query($pagres)or die("Error".mysql_error()); $CouponRow = mysql_num_rows($CouponRes); $total_records = mysql_num_rows($CouponRes); ?> <? print $title ?>