Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1032]PHP入門」目錄
MarkDown
5. 編輯與刪除資料
1. PHP開發環境與表單
1-1 post.php
1-2 index.php
2. 邏輯判斷及樣板引擎
2-1 index.php
2-2 post.php
2-3 index_tpl.html
3. MySQL的資料存取
3-1 index.php
3-2 post.php
3-3 post_tpl.html
3-4 eznews.sql
4. PHP函數與引入
4-1 post.php
4-2 index.php
4-3 list_tpl.html
4-4 function.php
5. 編輯與刪除資料
5-1 index.php
5-2 list_tpl.html
5-3 post.php
5-4 config.php
5-5 function.php
5-6 post_tpl.html
6. BootStrap各式應用
6-1 post.php
6-2 list_tpl.html
6-3 post_tpl.html
6-4 index.php
7. 置頂、計數器與 join
7-1 post.php
7-2 post_tpl.html
7-3 index.php
7-4 list_tpl.html
7-5 function.php
7-6 eznews.sql
8. 上傳與分頁
8-1 post.php
8-2 index.php
8-3 config.php
8-4 post_tpl.html
8-5 eznews.sql
9. 身份認證機制
9-1 eznews.sql
9-2 post_tpl.html
9-3 list_tpl.html
9-4 config.php
9-5 index.php
9-6 post.php
5-2 list_tpl.html
\[1032\]PHP入門 ============= ``` 發布新聞'; /*----流程控制----*/ switch ($op) { case 'view': //列出單一內容 $news_list=view($sn); $toolbar.="
回新聞列表
"; break; case 'delete': //刪除單一內容 delete($sn); header("location: {$_SERVER['PHP_SELF']}"); break; default: //列出所有內容 $news_list=list_news(); break; } /*----輸出----*/ show_page('list_tpl'); /*----所有函數----*/ //列出所有內容 function list_news(){ link_db(); //讀取eznews資料表所有欄位(日期大到小排列) $sql="select * from eznews order by post_time desc"; //傳回值存到 $result 以供抓取資料用 $result=mysql_query($sql) or die("{$sql}
".mysql_error()); $news_list="
列出所有新聞
新聞標題
發布時間
功能
"; //取回資料庫一筆資料,並以欄位名稱為索引的資料陣列 while($news=mysql_fetch_assoc($result)){ $title=empty($news['news_title'])?"無標題":$news['news_title']; $news_list.="
{$title}
{$news['post_time']}
刪除
編輯
"; //$news_list=$news_list."
{$news['news_title']}
"; } $news_list.="
"; return $news_list; } //顯示單一頁面 function view($sn=""){ link_db(); //讀取eznews資料表所有欄位,並指定某一筆特定資料 $sql="select * from eznews where sn='$sn'"; //傳回值存到 $result 以供抓取資料用 $result=mysql_query($sql) or die("{$sql}
".mysql_error()); $news=mysql_fetch_assoc($result); $news_content=nl2br($news['news_content']); $one_news="
{$news['news_title']}
{$news_content}
"; return $one_news; } //刪除單一頁面 function delete($sn=""){ link_db(); //刪除指定某一筆特定資料 $sql="delete from eznews where sn='$sn'"; mysql_query($sql) or die("{$sql}
".mysql_error()); } ?> ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
55
人線上 (
17
人在瀏覽
線上書籍
)
會員: 0
訪客: 55
更多…