Rows($sql_num); $num1 = $r_num[0]['num1']; #-------------------------------------------------------------------------- if(isset($_REQUEST['id']) && intval($_REQUEST['id'])) { $ca_id = intval($_REQUEST['id']); $WHERE.=" AND A1.ca_id = '$ca_id' "; $strURL.='id='.$id."&"; } if(isset($_REQUEST['txtKEYWORD']) && trim($_REQUEST['txtKEYWORD'])<>"") { $txtKEYWORD = trim($_REQUEST['txtKEYWORD']); $strURL.='txtKEYWORD='.$txtKEYWORD."&"; $WHERE.=" AND A1.main_name like '%$txtKEYWORD%' "; } if(isset($_REQUEST['page']) && intval($_REQUEST['page'])) { $page1 = intval($_REQUEST['page']); $strURL.='page='.$page1."&"; } #-------------------------------------------------------------------------- $cur_dd = gmdate("d", time()+(7*3600)); $cur_mm = gmdate("m", time()+(7*3600)); $cur_yy = gmdate("Y", time()+(7*3600)); #LIST //dieu chinh: ORDER BY A1.vip ASC, A1.date_added DESC $sql = "SELECT A1.*, DATE_FORMAt(A1.date_added,'%d-%m-%Y') as date_added,A2.ci_name, A3.ca_name, DATE_FORMAt(A1.date_added,'%d') as dd, DATE_FORMAt(A1.date_added,'%m') as mm, DATE_FORMAt(A1.date_added,'%Y') as yy FROM tbl_company as A1 left join tbl_city as A2 on A2.ci_id = A1.ci_id left join tbl_category as A3 on A3.ca_id = A1.ca_id WHERE 1=1 ".$WHERE." AND A1.at_id = 1 ORDER BY A1.vip ASC, A1.click DESC, A1.account "; $result=@mysql_query($sql); $total_records=@mysql_num_rows($result); $record_per_page=$num1; $scroll=10; $page->set_qry_string($strURL); $page->set_page_data("company_address.php",$total_records,$record_per_page,$scroll,true,true,true); $r = array(); $i=$page1*$record_per_page-1; $j=-1; $result_show = mysql_query($page->get_limit_query($sql)); while($rows = mysql_fetch_array($result_show)) { $i++; $j++; $r[] = $rows; $r[$j]['n']= $i+1; $tem_dd = ""; if($rows['vip']<>1) { if($cur_yy==$rows['yy']) { if($cur_mm<=$rows['mm']) { $dd = $rows['dd'] + 30*($rows['mm']-$cur_mm); $tem_dd = $dd-$cur_dd; if($tem_dd<=7) { $r[$j]['new']="okie"; } else { $r[$j]['new']=""; } } else { $r[$j]['new']=""; } } else { $r[$j]['new']=""; } } else { $r[$j]['new']=""; } /* if($rows['vip']<>1 && ($k<=10)) { $k++; $r[$j]['new']="okie"; } else { $r[$j]['new']=""; } */ } $showPage=$page->get_page_nav(); $total_page=$page->total_page; $fN = $n_page*$record_per_page + 1; $tN = ($n_page+1)*$record_per_page; if($tN > $total_records) $tN=$total_records; #BANNER $sqlBanner = "SELECT * FROM tbl_banner WHERE ba_id = 2"; $rB = $db->Rows($sqlBanner); $smarty->assign('rB',$rB); #CITY $sql2 = "SELECT * FROM tbl_city"; $r2_id = $db->RowsField($sql2,'ci_id'); $r2_name = $db->RowsField($sql2,'ci_name'); #CATEGORY $sql3 = "SELECT * FROM tbl_category"; $r3_id = $db->RowsField($sql3,'ca_id'); $r3_name = $db->RowsField($sql3,'ca_name'); #-------------------------------------------------------------------------- $smarty->assign('r',$r); $smarty->assign("showPage",$showPage); $smarty->assign("total_page",$total_page); $smarty->assign("total_records",$total_records); $smarty->assign("fN",$fN); $smarty->assign("tN",$tN); $smarty->assign('ca_name',$ca_name); $smarty->assign('r2_id',$r2_id); $smarty->assign('r2_name',$r2_name); #-------------------------------------------------------------------------- $smarty->display($template_root.'company_address.tpl'); ?>