:::

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%3Ftbdsn%3D886%26tbsn%3D29

計數器

今天: 3833383338333833
昨天: 2489248924892489
總計: 8025815802581580258158025815802581580258158025815