#檢查資料表(ugm_p_news) if (!chk_isTable("{$WEB['moduleName']}_news")) { $sql = " CREATE TABLE `{$WEB['moduleName']}_news` ( `sn` int(10) unsigned NOT NULL auto_increment comment 'prod_sn', `kind` smallint(5) unsigned NOT NULL default 0 comment '分類', `title` varchar(255) NOT NULL default '' comment '名稱', `summary` text NULL comment '摘要', `content` text NULL comment '內容', `price` int(10) unsigned NOT NULL comment '價格', `amount` int(10) unsigned NOT NULL comment '數量', `enable` enum('1','0') NOT NULL default '1' comment '狀態', `choice` enum('1','0') NOT NULL default '0' comment '精選', `date` int(10) unsigned NOT NULL default 0 comment '建立日期', `sort` smallint(5) unsigned NOT NULL default 0 comment '排序', `counter` int(10) unsigned NOT NULL default 0 comment '人氣', `icon` varchar(255) NOT NULL default '' comment '圖示', PRIMARY KEY (`sn`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; createTable($sql); }
<{* 新聞管理 *}> <{elseif $WEB.file_name == "admin_news.php"}> <{include file="tpl/admin_news.tpl"}>
<li><a href="admin_news.php">新聞管理</a></li>
########################################################### # 撈商品資料 ########################################################### function get_news() { global $db, $smarty; #撈商品資料 $sql = "select a.`sn`,a.`title`,a.`summary`,a.`icon` from `ugm_show_news` as a where a.`enable`='1' order by a.`sort` desc ";//die($sql); $result = $db->query($sql) or redirect_header("", 3000, $db->error."\n".$sql,true); $rows=[]; while($row = $result->fetch_assoc()){ #過濾資料 $row['sn'] = intval($row['sn']); $row['title'] = htmlspecialchars($row['title'], ENT_QUOTES); $row['summary'] = htmlspecialchars($row['summary'], ENT_QUOTES); $row['icon'] = htmlspecialchars($row['icon'], ENT_QUOTES); $rows[] = $row; } //print_r($rows);die(); $smarty->assign("newss", $rows);//送至樣板 }
<{foreach from=$newss item=row}> <div class="col-lg-3 col-md-6 text-center"> <div class="service-box mt-5 mx-auto"> <i class="fa fa-4x <{$row.icon}> text-primary mb-3 sr-icons"></i> <h3 class="mb-3"><{$row.title}></h3> <p class="text-muted mb-0"><{$row.summary}></p> </div> </div> <{/foreach}>