prefix("phone_book") . "` where `sn` = '{$sn}' "; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); $all = $xoopsDB->fetchArray($result); //以下會產生這些變數: $sn, $cate_sn, $name, $birthday, $phone, $email, $zip, $county, $city, $addr, $note foreach ($all as $k => $v) { $$k = $v; } //取得分類資料(phone_book_cate) $phone_book_cate_arr = get_phone_book_cate($cate_sn); //過濾讀出的變數值 $name = $myts->htmlSpecialChars($name); $birthday = $myts->htmlSpecialChars($birthday); $phone = $myts->htmlSpecialChars($phone); $email = $myts->htmlSpecialChars($email); $zip = $myts->htmlSpecialChars($zip); $county = $myts->htmlSpecialChars($county); $city = $myts->htmlSpecialChars($city); $addr = $myts->htmlSpecialChars($addr); $note = $myts->displayTarea($note, 0, 1, 0, 1, 1); $xoopsTpl->assign('sn', $sn); $xoopsTpl->assign('cate_sn', $cate_sn); $xoopsTpl->assign('cate_sn_title', $phone_book_cate_arr['cate_title']); $xoopsTpl->assign('name', $name); $xoopsTpl->assign('birthday', $birthday); $xoopsTpl->assign('phone', $phone); $xoopsTpl->assign('email', $email); $xoopsTpl->assign('zip', $zip); $xoopsTpl->assign('county', $county); $xoopsTpl->assign('city', $city); $xoopsTpl->assign('addr', $addr); $xoopsTpl->assign('note', $note); $xoopsTpl->assign('action', $_SERVER['PHP_SELF']); $xoopsTpl->assign('now_op', 'show_one_phone_book'); $sql = "select cate_sn, cate_title from `" . $xoopsDB->prefix("phone_book_cate") . "` where `cate_enable` = '1' order by cate_sort"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); while(list($csn, $cate_title) = $xoopsDB->fetchRow($result)){ $arr[$csn]=$cate_title; } $arr['selected']=$cate_sn; $json=json_encode($arr); $json=str_replace('"',"'",$json); include_once XOOPS_ROOT_PATH."/modules/tadtools/jeditable.php"; $file="save_phone_book.php"; $jeditable = new jeditable(); //此處加入欲直接點擊編輯的欄位設定 $jeditable->setTextCol("#name", $file, '240px', '36px', "{'sn':$sn }", "點擊編輯"); $jeditable->setTextAreaCol("#note", $file, '500px', '150px', "{'sn':$sn, 'op':'textarea'}", "點擊編輯"); $jeditable->setSelectCol("#cate_sn", $file, $json, "{'sn' : $sn}", "點擊編輯"); $jeditable_set=$jeditable->render(); $xoopsTpl->assign("jeditable_set",$jeditable_set); } //以流水號取得某筆phone_book_cate資料 function get_phone_book_cate($cate_sn = '') { global $xoopsDB; if (empty($cate_sn)) { return; } $sql = "select * from `" . $xoopsDB->prefix("phone_book_cate") . "` where `cate_sn` = '{$cate_sn}'"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); $data = $xoopsDB->fetchArray($result); return $data; } //列出所有phone_book資料 function list_phone_book($def_cate_sn = "", $def_city="") { global $xoopsDB, $xoopsTpl, $isAdmin; $xoopsTpl->assign('action', $_SERVER['PHP_SELF']); $xoopsTpl->assign('isAdmin', $isAdmin); $xoopsTpl->assign('now_op', 'list_phone_book'); $xoopsTpl->assign('cate_sn', $cate_sn); $xoopsTpl->assign('cate_arr', get_phone_book_cate_arr()); //擷取縣市陣列 $county_arr=get_county_arr(); //套用到樣板 $xoopsTpl->assign('county_arr', $county_arr); } //擷取縣市陣列 function get_county_arr(){ global $xoopsDB; $sql = "select county from `" . $xoopsDB->prefix("phone_book") . "` group by county order by zip"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); while (list($county) = $xoopsDB->fetchRow($result)) { $county_arr[] = $county; } return $county_arr; } //取得 phone_book_cate 的所有資料陣列 function get_phone_book_cate_arr() { global $xoopsDB; $sql = "select * from `" . $xoopsDB->prefix("phone_book_cate") . "` where `cate_enable` = '1'"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); while ($data = $xoopsDB->fetchArray($result)) { $cate_sn = $data['cate_sn']; $all[$cate_sn] = $data; } return $all; } /*-----------執行動作判斷區----------*/ include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php'); $op = system_CleanVars($_REQUEST, 'op', '', 'string'); $city = system_CleanVars($_REQUEST, 'city', '', 'string'); $sn = system_CleanVars($_REQUEST, 'sn', '', 'int'); $cate_sn = system_CleanVars($_REQUEST, 'cate_sn', '', 'int'); switch ($op) { /*---判斷動作請貼在下方---*/ default: if (empty($sn)) { list_phone_book($cate_sn,$city); } else { show_one_phone_book($sn); } break; /*---判斷動作請貼在上方---*/ } /*-----------秀出結果區--------------*/ $xoopsTpl->assign("toolbar", toolbar_bootstrap($interface_menu)); $xoopsTpl->assign("isAdmin", $isAdmin); include_once XOOPS_ROOT_PATH . '/footer.php'; ```
進階搜尋
34人線上 (3人在瀏覽線上書籍)
會員: 0
訪客: 34