:::

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);
    }

:::

書籍目錄

展開 | 闔起

快速登入


http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D886%26tbsn%3D29

計數器

今天: 777777777
昨天: 3068306830683068
總計: 8077282807728280772828077282807728280772828077282