:::

6-8 過濾所有讀出的函數

  1. 過濾 show_action 函數
    //顯示單一活動
    function show_action($action_id)
    {
        global $xoopsDB, $xoopsTpl;
        $tbl               = $xoopsDB->prefix('actions');
        $sql               = "SELECT * FROM `{$tbl}` WHERE `action_id` ='{$action_id}'";
        $result            = $xoopsDB->query($sql) or web_error($sql);
        $action            = $xoopsDB->fetchArray($result);
        $myts              = MyTextSanitizer::getInstance();
        $action['title']   = $myts->htmlSpecialChars($action['title']);
        $action['content'] = $myts->displayTarea($action['content'], 1, 1, 1, 1, 0);
        $xoopsTpl->assign('action', $action);
    }
    
  2. 過濾 list_action 函數

    //顯示活動列表
    function list_action()
    {
        global $xoopsDB, $xoopsTpl;
    
        $tbl    = $xoopsDB->prefix('actions');
        $sql    = "SELECT * FROM `{$tbl}` WHERE `enable` ='1' AND `end_date` > now() ORDER BY `end_date` DESC";
        $result = $xoopsDB->query($sql) or web_error($sql);
        $myts   = MyTextSanitizer::getInstance();
        while ($action = $xoopsDB->fetchArray($result)) {
            $action['title']   = $myts->htmlSpecialChars($action['title']);
            $action['content'] = $myts->displayTarea($action['content'], 1, 1, 1, 1, 0);
            $actions[]         = $action;
        }
        $xoopsTpl->assign('actions', $actions);
    }

:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D29%26tbdsn%3D886

計數器

今天: 400400400
昨天: 3254325432543254
總計: 8071172807117280711728071172807117280711728071172