Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1002] PHP入門班」目錄
MarkDown
15-3 上課範例:header.php
1. PHP入門
2. 使用者輸入介面設計
2-1 上課範例:index.php
2-2 上課範例:save.php
3. PHP變數與常數
3-1 上課範例:a1.php
4. PHP資料類型與建立資料表
4-1 上課範例:add_class.php
5. 連線資料庫及運算元
5-1 上課範例:save_class.php
5-1 上課範例:add_class.php
6. 讀取資料庫及PHP陣列
6-1 上課範例:add_class.php
6-2 上課範例:save_class.php
6-3 上課範例:index.php
7. 編輯與刪除功能
7-1 上課範例:index.php
7-2 上課範例:add_class.php
7-3 上課範例:save_class.php
8. 函數與小強佈景
8-1 上課範例:index.php
8-2 上課範例:add_class.php
8-3 上課範例:save_class.php
9. 流程控制與迴圈
9-1 上課範例:add_class.php
9-2 上課範例:theme.html 樣板檔
9-3 上課範例:save_class.php
9-4 上課範例:index.php
9-5 上課範例:header.php
9-6 上課範例:function.php
10. 練習練習再練習!
10-1 上課範例:index.php
10-2 上課範例:add_class.php
10-3 上課範例:save_class.php
10-4 上課範例:index.php(整合版)
10-5 上課範例:header.php(整合版)
11. 建立學習收藏的發布頁
11-1 上課範例:class.php
11-2 上課範例:header.php
11-3 上課範例:tad0616.sql
11-4 上課範例:blank.php 空白樣板
11-5 上課範例:index.php
12. 兩個資料表的結合
12-1 index.php
13. 資料檢查
13-1 上課範例:index.php
13-2 上課範例:header.php
13-3 上課範例:function.php
13-4 上課範例:class.php
14. 請完成基本功能囉~
14-1 上課範例:index.php(完成版)
15. 認證與session
15-1 上課範例:class.php
15-2 上課範例:config.php
15-3 上課範例:header.php
15-4 上課範例:index.php
16. 分頁與編輯器
16-1 上課範例:index.php
16-2 上課範例:header.php
17. 用PHP上傳檔案
17-1 上課範例:index.php
18. 資料搜尋
18-1 上課範例:index.php
18-2 上課範例:theme.html
16. 分頁與編輯器
\[1002\] PHP入門班 =============== ``` $class_name"; } $main="
$opt
密碼:
"; return $main; } //進行認證 function leader_login($class_sn='',$pass=''){ if(empty($class_sn) or empty($pass))return; //設定SQL語法 $sql="select passwd from `tncomu_class` where class_sn='{$class_sn}'"; $result=mysql_query($sql) or die("無法執行:".mysql_error()); list($passwd)=mysql_fetch_row($result); if($passwd==$pass){ $_SESSION['isLeader']=$class_sn; } } //秀出某一篇文章 function show_article($sn=null){ $now_seme=get_seme(); $sql="update `tncomu_article` set `counter`=`counter`+1 where sn='$sn'"; mysql_query($sql) or die("無法執行:".mysql_error()); //設定SQL語法 $sql="select a.* , b.class_name from `tncomu_article` as a left join `tncomu_class` as b on a.class_sn=b.class_sn where a.enable='1' and a.sn='$sn'"; //執行SQL語法 $result = mysql_query($sql) or die("無法執行:".mysql_error()); $data=mysql_fetch_assoc($result); $data['content']=nl2br($data['content']); $main="
「{$data['stud_name']}」的學習收藏
{$data['class_name']}
{$data['content']}
{$data['post_time']}
"; return $main; } //列出所有文章 function list_article(){ $now_seme=get_seme(); //設定SQL語法 $sql="select a.* , b.class_name from `tncomu_article` as a left join `tncomu_class` as b on a.class_sn=b.class_sn where a.enable='1' and b.seme='$now_seme' order by a.post_time desc"; //執行SQL語法 $result = mysql_query($sql) or die("無法執行:".mysql_error()); $main="
所屬班級
學員姓名
發布日期
人氣
相關功能
"; $i=2; while($data=mysql_fetch_assoc($result)){ $color=($i % 2)?"white":"#D0D0D0"; $i++; $tool=($_SESSION['isLeader'])?"
刪除
|
編輯
":""; $main.="
{$data['class_name']}
{$data['stud_name']}
{$data['post_time']}
{$data['counter']}
$tool
"; } $main.="
"; return $main; } //輸入學習收藏的表單 function article_form($sn=''){ $next_op="insert"; //初始值設定 $data['stud_name'] = $data['class_sn'] = $data['content'] = $data['enable'] = $radio1 = $radio0 = ""; if($sn){ //設定SQL語法 $sql="select * from `tncomu_article` where sn='{$sn}'"; //執行SQL語法 $result=mysql_query($sql) or die("無法執行:".mysql_error()); //擷取資料回來存到 $data $data=mysql_fetch_assoc($result); //還原下拉選單預設值 $radio1=($data['enable']=="1")?"checked":""; $radio0=($data['enable']=="0")?"checked":""; $next_op="update"; } $now_seme=get_seme(); $sql="select class_sn,class_name from tncomu_class where access='1' and seme='{$now_seme}' "; $result=mysql_query($sql) or die($sql); $opt=""; while(list($class_sn , $class_name) = mysql_fetch_row($result)){ $selected = ($class_sn == $data['class_sn'])?"selected":""; $opt.="
$class_name
"; } $main="
輸入學習收藏
您的姓名:
{$now_seme}班級:
請選擇{$now_seme}班級
$opt
學習收藏內容
{$data['content']}
設定密碼:
是否發布?
發布
暫不發布
"; return $main; } //執行儲存動作 function insert_article(){ //過濾姓名 $stud_name=trim($_POST['stud_name']); $stud_name=strip_tags($stud_name); $stud_name = (! get_magic_quotes_gpc()) ? addslashes($stud_name) : $stud_name; $stud_name=htmlspecialchars($stud_name); //過濾內容 $_POST['content'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['content']) : $_POST['content']; $_POST['content']=htmlspecialchars($_POST['content']); //過濾密碼 $_POST['text_passwd'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['text_passwd']) : $_POST['text_passwd']; $class_sn=intval($_POST['class_sn']); $sql="INSERT INTO `tncomu_article`(`stud_name`, `content`, `post_time`, `enable`, `class_sn`, `mode`, `text_passwd`) VALUES ('{$stud_name}' , '{$_POST['content']}' , now(), '{$_POST['enable']}', '{$class_sn}', '文字', '{$_POST['text_passwd']}')"; mysql_query($sql) or die(mysql_error().$sql); return "儲存完畢"; } //執行更新動作 function update_article($sn=''){ //過濾姓名 $stud_name=trim($_POST['stud_name']); $stud_name=strip_tags($stud_name); $stud_name = (! get_magic_quotes_gpc()) ? addslashes($stud_name) : $stud_name; $stud_name=htmlspecialchars($stud_name); //過濾內容 $_POST['content'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['content']) : $_POST['content']; $_POST['content']=htmlspecialchars($_POST['content']); //過濾密碼 $_POST['text_passwd'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['text_passwd']) : $_POST['text_passwd']; $class_sn=intval($_POST['class_sn']); $sql="update `tncomu_article` set `stud_name`='{$stud_name}', `content`='{$_POST['content']}', `post_time`=now(), `enable`='{$_POST['enable']}', `class_sn`='{$_POST['class_sn']}' where `sn`='{$sn}'"; mysql_query($sql) or die(mysql_error().$sql); return "儲存完畢"; } //刪除文章資料 function delete_article($sn=null){ //設定SQL語法 $sql="delete from `tncomu_article` where sn='{$sn}'"; //執行SQL語法 mysql_query($sql) or die("無法執行:".mysql_error()); //執行完轉向 header("location: {$_SERVER['PHP_SELF']}"); } ?> ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
67
人線上 (
14
人在瀏覽
線上書籍
)
會員: 0
訪客: 67
更多…