收藏 分享(赏)

PHP_talk.ppt

上传人:gsy285395 文档编号:4529517 上传时间:2019-01-02 格式:PPT 页数:10 大小:89KB
下载 相关 举报
PHP_talk.ppt_第1页
第1页 / 共10页
PHP_talk.ppt_第2页
第2页 / 共10页
PHP_talk.ppt_第3页
第3页 / 共10页
PHP_talk.ppt_第4页
第4页 / 共10页
PHP_talk.ppt_第5页
第5页 / 共10页
点击查看更多>>
资源描述

1、留言版,1.先Create一個留言板的table mysql use dbname; 建立gbook table mysql CREATE TABLE gbook(id int unsigned not null auto_increment,name char(20) not null, email char(50),face tinyint,ip char(20),ctime datetime,title char(50) not null, content text,primary key(id); 建立一個可以從internet連線進入學校存取gbook的user mysql GRAN

2、T insert,update,delete,select on dbname.gbook to iuserlocalhost identified by 1234; 2.一般設定檔:設定資料庫參數 ,新增留言 add.php,新增留言資料:範例 /database連結 $link=mysql_pconnect($HOST,$USER,$PASS); /選擇資料庫 mysql_select_db($DB,$link); /取得來源ip $ip=getenv(“REMOTE_ADDR“); /新增SQL語法 $str=“INSERT INTO $TABLE1 (name,email,face,i

3、p,ctime,title,content) VALUES($name,$email,$face,$ip,now(),$title,$content)“; /執行SQL命令 mysql_query($str,$link);,新增留言原始碼,您的資料已經新增了“; echo “觀看留言“; exit; ?留言板資料新增新增留言 觀看留言姓 名: 電子郵件: 心 情:普通高興難過快樂 留言主旨:,瀏覽留言 view.php,觀看留言資料:範例 /讀取資料,var1,var2.為欄位 list($var1,$var2,.)=mysql_fetch_row($result); /重覆讀取多筆資料 wh

4、ile(list($id,$name,$email,$face,$ip,$ctime,$title,$content)=mysql_fetch_row($result) ,瀏覽留言程式碼,顯示留言板留言板 新增留言“; echo “; echo “留言者 :“.$name.“; echo “電子郵件:“.$email.“; echo “心情 :“.$FACE$face.“; echo “日期 :“.$ctime.“; echo “IP :“.$ip.“; echo “主旨 :“.$title.“; echo nl2br($content).“; echo “; echo “; ?,nl2br,

5、nl2br - Inserts HTML line breaks before all newlines in a string Description string nl2br ( string string) Returns string with inserted before all newlines. Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions before 4.0.5 will return string with inserted before newlines inste

6、ad of .,Example 1. using nl2br(), this will output :,分頁view_page.php,/-$num=mysql_num_rows($result); /總筆數if ($num)$pages=intval($num-1)/3)+1; /總頁數if ($page$pages) $page=$pages;mysql_data_seek($result,($page-1)*3); /重新取的資料/-,分頁view_page.php,“; echo “; echo “編號 :“.$record0.“; echo “留言者 :“.$record1.“; echo “電子郵件:“.$record2.“; echo “心情 :“.$record3.“; echo “日期 :“.$record5.“; echo “IP :“.$record4.“; echo “主旨 :“.$record6.“; echo nl2br($record7).“; echo “; echo “; ?,分頁view_page.php,“前一頁 | “下一頁頁數: / 跳頁“第頁,分頁view_page.php,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 网络科技 > PHP资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报