Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1032]PHP入門」目錄
MarkDown
6-4 index.php
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
7-1 post.php
\[1032\]PHP入門 ============= [](http://www.tad0616.net/uploads/tad_book3/file/1032/7.pdf) ### 一、 整理post.php 1. 顏我們將發布表單的HTML語法放在post\_tpl.html樣板檔中,如此,會造成post.php不好維護的問題,因此,我們將發布表單做成函數,並傳回完整表單語法。 2. 可利用Heredoc定界符<<<的用法(左邊不可有任何空白)來做: ``` $form = <<
{$news['counter']} ``` ### 四、 製作圖形計數器 (補充) 1. 請建立一個新檔案,例如:counter.php,其內容如下: ``` ``` 2. imagecreatetruecolor() 用來建立一個全彩的圖片格式,裡面分別是寬和高。 3. imagecolorallocate() 用來設定顏色,分別為 R(紅)G(綠)B(藍),值從 0~255 4. imagestring() 用來加上文字,第二個參數是字形型,有1~6種,第三、四個參數是x,y的位置,接著填入欲呈現數字(或英文),最後填入顏色。 5. imagepng()是做成png圖檔 6. imagedestroy()用來釋放圖檔佔用的記憶體。 7. 最後,請在要呈現的地方,利用HTML圖片語法即可秀出該圖: ```
``` ### 五、 一次讀兩個以上的資料表 1. 關聯資料表方便的地方就是:一次可以讀取兩個以上的資料表,簡易語法如下: ``` select a.* , b.* , c.* from `資料表1` as a join `資料表2` as b on a.`索引欄位`= b.`索引欄位` join `資料表3` as c on b.`索引欄位`= c.`索引欄位` where a.欄位='值' and …. ``` 2. 「left join」代表以左邊為主,順便到右邊撈撈看有無指定的資料。 3. 「right join」代表以右邊為主,順便到左邊撈撈看有無指定的資料。 4. 「join」代表兩邊都要同時有資料,否則該筆資料不會出現。 5. 以本例而言,讀出新聞順便讀出新聞分類的寫法: ``` select a.*,b.* from eznews as a left join eznews_cate as b on a.cate_sn=b.cate_sn order by a.post_time desc ``` 6. 此處用left join,這樣才不會因為沒有設定新聞分類而導致新聞出不來。 ### 六、 其他常用的join的方式 1. inner join: ``` select a.* , b.* from `資料表1` as a , `資料表2` as b where a.`索引欄位`= b.`索引欄位` ``` 2. natural join:自動搜尋兩資料表相同欄位,自動對應 ``` select a.* , b.* from `資料表1` as a natural join `資料表2` as b ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
131
人線上 (
56
人在瀏覽
線上書籍
)
會員: 0
訪客: 131
更多…