set_filenames(array("body" => $html_file)); $start = formatstring((isset($_REQUEST['start'])) ? $_REQUEST['start'] : 0) ; $pagerow = 25; $bhxh = $prefix.'question'; $bhxh_faq = $prefix.'faq'; $bhxh_pre = question_; $menu1 = $prefix.'menu_1'; $menu2 = $prefix.'menu_2'; $id = $_REQUEST['value'] + 0; if(isset($_REQUEST['value'])) { $sql = "select * from ".$menu2." where menu_2_id = '".$id."' and menu_1_id = '".$hoidap."'"; $result = mysql_query($sql) or die("Khong the truy cap menu_2"); $row = $db->sql_fetchrowset($result); if(count($row) > 0) { $template->assign_block_vars("bhxh", array( "NAME" => $hoidap_title.' - '.$row[0]['menu_2_name'], )); $sql = "select * from ".$menu2." where menu_2_sub = '".$id."'"; $result = mysql_query($sql) or die("Khong the truy cap menu_2"); $row = $db->sql_fetchrowset($result) ; if(count($row)>0) { $template->assign_block_vars("bhxh.list", array()); for ($i=0 ; $iassign_block_vars("bhxh.list.menu_1", array( "NAME" => $row[$i]['menu_2_name'], "LINK" => ($row[$i]['menu_2_link'] == "")?($row[$i]['menu_1_link']."?value=".$row[$i]['menu_2_id']):$row[$i]['menu_2_link'], )); } } else { if($id == 61) // liet ke cau hoi thuong gap { $bhxh_pre = faq_; $keyword = formatstring($_REQUEST['keyword']); if($keyword != '') $where = " where lower(faq_question) like '%".strtolower($keyword)."%' or lower(faq_answer) = '%".strtolower($keyword)."%'"; else $where = ''; $sql = "select * from ".$bhxh_faq.$where." order by faq_id ASC"; $tmp_sql = $sql; $sql.=" limit ".$start.",".$pagerow; $result = mysql_query($sql) or die("Khong the truy cap question"); $row = $db->sql_fetchrowset($result); $template->assign_block_vars("bhxh.search", array("id" => $id)); $template->assign_block_vars("bhxh.record", array()); for ($i=0 ; $iassign_block_vars("bhxh.record.faq", array( "ID" => $row[$i][$bhxh_pre.'id'], "STT" =>$i+1+$start, "QUESTION" => $row[$i][$bhxh_pre.'question'], "ANSWER" => $row[$i][$bhxh_pre.'answer'], )); } // phan trang $result = $db->sql_query($tmp_sql) ; $row = $db->sql_numrows($result) ; $numpage = (int)($row/$pagerow); if($row > $pagerow) $numpage = (($row % $pagerow) > 0) ? $numpage + 1 : $numpage ; if ( $numpage > 1 ) { $page = "" ; for ( $i = 1 ; $i <= $numpage ; $i++ ) { if ( $i * $pagerow == $start + $pagerow) { $page .="".$i."" ; } else { $start1 = $i * $pagerow - $pagerow ; $page .= "".$i."  " ; } } } if ( $start < $row-$pagerow ) { $next = $start + $pagerow ; $page .= " ".$xemtiep."" ; } if($numpage>1) $template->assign_block_vars("bhxh.record.page",array( "PAGE" => $page) ) ; /// phan trang } else { $sql = "select * from ".$bhxh." where ".$bhxh_pre."group = '".$id."' and ".$bhxh_pre."ok = '1' order by ".$bhxh_pre."id DESC"; $result = mysql_query($sql) or die("Khong the truy cap question"); $row = $db->sql_fetchrowset($result); if(count($row) > 0) { $template->assign_block_vars("bhxh.record", array()); for ($i=0 ; $iassign_block_vars("bhxh.record.row", array( "ID" => $row[$i][$bhxh_pre.'id'], "TITLE" => $row[$i][$bhxh_pre.'title'], "QUESTION" => $row[$i][$bhxh_pre.'detail'], "ANSWER" => $row[$i][$bhxh_pre.'answer'], "REG" => $row[$i][$bhxh_pre.'reg'], "NAME" => $row[$i][$bhxh_pre.'name'], "EMAIL" => $row[$i][$bhxh_pre.'email'], )); } } else { $template->assign_block_vars("bhxh.record", array()); $template->assign_block_vars("bhxh.record.alert", array( "ALERT" => $alert, )); } } } } else { $sql = "select * from ".$menu2." where menu_1_id = '".$hoidap."' and menu_2_sub = '0'"; $result = mysql_query($sql) or die("Khong the truy cap menu_2"); $row = $db->sql_fetchrowset($result); if(count($row) > 0) { $template->assign_block_vars("bhxh", array( "NAME" => $hoidap_title, )); $template->assign_block_vars("bhxh.list", array()); for ($i=0 ; $iassign_block_vars("bhxh.list.menu_1", array( "NAME" => $row[$i]['menu_2_name'], "LINK" => ($row[$i]['menu_2_link'] == "")?($row[$i]['menu_1_link']."?value=".$row[$i]['menu_2_id']):$row[$i]['menu_2_link'], )); } } } } else { $sql = "select * from ".$menu2." where menu_1_id = '".$hoidap."' and menu_2_sub = '0'"; $result = mysql_query($sql) or die("Khong the truy cap menu_2"); $row = $db->sql_fetchrowset($result); if(count($row) > 0) { $template->assign_block_vars("bhxh", array( "NAME" => $hoidap_title, )); $template->assign_block_vars("bhxh.list", array()); for ($i=0 ; $iassign_block_vars("bhxh.list.menu_1", array( "NAME" => $row[$i]['menu_2_name'], "LINK" => ($row[$i]['menu_2_link'] == "")?($row[$i]['menu_1_link']."?value=".$row[$i]['menu_2_id']):$row[$i]['menu_2_link'], )); } } } $template->pparse("body"); include('include/right.php') ; include('include/page_footer.php') ; ?>