文档详情

PHPMYSQL留言板源码(终极完整版).doc

发布:2017-08-01约9.12千字共12页下载文档
文本预览下载声明
数据库结构:(库名:lyb) 表一: admin 字段: id(int11) name(varchvr) password(varchvr) 表二: lo 字段: id(int11) username(varchvr) sex(varchvr) qq(varchvr) email(varchvr) info(text) ip(varchvr) submit_time(datetime) 1 conn.php(连接数据库文件) ?php mysql_connect(localhost,root,);//连接数据库 mysql_select_db(lyb);//选择数据库 ? 2 header.php(公用头部文件) 代码: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN /TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=/1999/xhtml head meta http-equiv=Content-Type content=text/html; charset=gb2312 / title银子留言板 Version 1.0/title /head link href=css.css rel=stylesheet type=text/css / body ?php session_start(); ? div id=head div id=head_l ul lia href=index.php偶要看留言/a/li lia href=post.php偶要发表/a/li ?php //session_start();//DOFY同学指出本句前不能有任何输出内容,就此改正 if($_SESSION[key]==1){//如果获取的SESSION为1则显示管理项 ? lia href=adminexit.php退出管理/a/li ? } else { ? lia href=admin.php偶要管理/a/li ?}? /ul /div div id=head_r银子留言板 Version 1.0/div /div 3 footer.php(公用底部文件) 代码: ?php $counterFile=conter.xml; function displayCounter($counterFile){ $fp = fopen($counterFile,rw); $num = fgets($fp,5); $num += 1; print div id=\footer\银子留言板 Version 1.0 您是第 .$num. 位无聊的银/div; exec(rm -rf $counterFile); exec(echo $num $counterFile); } if(!file_exists($counterFile)){ exec(echo 0 $counterFile); } displayCounter($counterFile); ? /body /html 4 index.php(首页) 代码: ?php require_once(conn.php); require_once(header.php); session_start(); //分页代码开始 $pagesize = 10;//设置每页显示条数 $rs = mysql_query(select count(*) from lo);//取得记录总数,计算总页数用 $myrow = mysql_fetch_array($rs); $numrows = $myrow[0];//计算总记录 $pages = intval($numrows/$pagesize); if($numrows%$pagesize)$pages++;//设置页数 if(isset($_GET[page])) { $page = intval($_GET[page]); } else { $page = 1;//设为第一页 } $offset = $pagesize*($1);//计算记录偏移量 //分页代码结束 $sql = select id,username,sex,qq,email,info,ip,DATE_FORMAT(submit_time, %Y年%m月%d日 %T ) from lo order by id desc limit $offset,$pagesize;//用到了DATE-FORMAT格式化
显示全部
相似文档