:::

6-4-4 觀看單一文章的函式

  1. 讀出單一文章的功能算簡單,只要取出一筆,故不需要跑迴圈,順便取出縮圖即可,同樣的,記得過濾,避免XSS。
    // 觀看某篇文章
    function show($id)
    {
        global $db;
        $sql = "SELECT * FROM `articles` WHERE `id` = ?";
        $sth = $db->prepare($sql);
        $sth->execute([$id]);
        $news = $sth->fetch(PDO::FETCH_ASSOC);
        // 取得縮圖
        $news['files'] = get_thumbs($id);
        $news = filter_var_array($news, FILTER_SANITIZE_STRING);
        return $news;
    }
    

     


:::

書籍目錄

展開 | 闔起

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

計數器

今天: 4309430943094309
昨天: 5069506950695069
總計: 5134757513475751347575134757513475751347575134757