1 / 21
文档名称:

PHP MYSQL新手学习实例代码(留言板).doc

格式:doc   大小:54KB   页数:21页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

PHP MYSQL新手学习实例代码(留言板).doc

上传人:雾里看花 2019/5/6 文件大小:54 KB

下载得到文件列表

PHP MYSQL新手学习实例代码(留言板).doc

文档介绍

文档介绍:Forpersonaluseonlyinstudyandresearch;mercialuse膂PHP+MYSQL新手学****实例代码(留言板)螇袈数据库结构:(库名: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、(连接数据库文件)羅螀<?php莈mysql_connect("localhost","root","");//连接数据库***mysql_select_db("lyb");//选择数据库肂?>蒂***2、(公用头部文件)***蒃<!DOCTYPEhtmlPUBLIC"-//W3C////EN""/xhtml1/DTD/xhtml1-">羀<htmlxmlns="9/xhtml">膀<head>芇<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>袄<title></title>蚂</head>罿<linkhref=""rel="stylesheet"type="text/css"/>莇<body>芅<divid="head">腿<divid="head_l">螇<ul>蒇<li><ahref="">偶要看留言</a></li>蒁<li><ahref="">偶要发表</a></li>袁<?php蒆session_start();薇if($_SESSION["key"]==1){//如果获取地SESSION为1则显示管理项袂?>艿<li><ahref="">退出管理</a></li>蕿<?蚇}芃else羁{芈?>蚆<li><ahref="">偶要管理</a></li>蚄<?}?>葿</ul>肇</div>螆<divid="head_r"></div>肅</div>膁肀3、(公用底部文件)袆膂袃<?php衿$counterFile="";羆functiondisplayCounter($counterFile){薃$fp=fopen($counterFile,"rw");莀$num=fgets($fp,5);蚈$num+=1;肆print"<divid=\"footer\">   您是第 "."$num"." 位无聊地银</div>";羄exec("rm-rf$counterFile");肂exec("echo$num>$counterFile");莆}膆if(!file_exists($counterFile)){莄exec("echo0>$counterFile");薀}葿displayCounter($counterFile);芆?>薁节</body>膈</html>芆羂4、(首页)蚀羇莅<?php莃require_once("");莂require_once("");羀session_start();蒅螄//分页代码开始袀$pagesize=10;//设置每页显示条数蝿$rs=mysql_query("selectcount(*)fromlo");//取得记录总数,计算总页数用薅$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*($page-1);//计算记录偏移量蒃//分页代码结束莂腿螈$sql="selectid,username,sex,qq,email,info,ip,DATE_FORMAT(submit_time,'%Y年%m月%d日%T')fromloorderbyiddesclimit$offs