一个分页的论坛_php基础
程序员文章站
2024-01-08 19:31:34
...
-------------------------------论坛--------------------------
数据表
create table guest(id int not null auto_increment,primary key(id),title varchar(50),email varchar(30),homepage varchar(30),name varchar(30),text text,relay int,r_time date)
create table relay(id int not null auto_increment,primary key(id),title int,email varchar(30),name varchar(30),text text)
-------------------------index.php--------------------------
$db =mysql_connect("localhost", "****","****");
mysql_select_db("****",$db);
@$result = mysql_query("SELECT * FROM guest order by id desc",$db);
$i=0;
while($myrow = mysql_fetch_row($result)) {
$guestbook[$i][0] = $myrow[0];
$guestbook[$i][1] = $myrow[1];
$guestbook[$i][2] = $myrow[2];
$guestbook[$i][3] = $myrow[4];
$guestbook[$i][4]=$myrow[6];
$guestbook[$i][5]=$myrow[7];
$i++;
} //读入数组
mysql_close($db) ;
echo "-----------------------------共[";
if ($q!="") {
$page = $q;
} else {
$page = 0;
}
$i=count($guestbook);
$msgnum=20; // 每页20笔
$start = $page * $msgnum;
$end = $start + $msgnum;
if ($end > $i) $end=$i;
$totalpage=$i/$msgnum;
for ($i=0; $i if ($i!=$page) {
echo " $i";
} else {
echo " $i";
}
}
echo "]页-----------------------------
"; printf("");
echo "
";
echo "";
";
echo "
";
printf("添加主题");
?>
------------------------------444.php--------------------------------
$db =mysql_connect("localhost", "****","****");
mysql_select_db("****",$db);
@$result = mysql_query("SELECT * FROM guest where id='$id'",$db);
echo "";
"; echo "
"; echo "
"; echo "-------------------------------共[";
for ($i=0; $i if ($i!=$page) {
echo " $i";
} else {
echo $i;
}
} echo "]页---------------------------------"; echo "
";
echo "回复";echo "
";
echo "浏览主题";
?>
--------------------------------333.php-----------------------------
if (!$t){
if ($text==""&$email==""&$name==""){echo "*必填";echo "返回"; }
else { if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)){
$text = base64_encode($text); //检验邮件地址是否合法
$db =mysql_connect("localhost", "****","****");
$time=date("y-m-d");
mysql_select_db("****",$db);
$sql="insert into relay values('','$title','$email','$name','$text')";
$result = mysql_query($sql);
$num=$num+1;
$sql="update guest set relay='$num',r_time='$time' where id='$title'";
$result=mysql_query($sql);
mysql_close();
echo "";
}
else { echo "邮件地址无效"; echo "返回";}
} }
else
{ ?> }
?>
-----------------------------------www.php--------------------------
if ($title!=""&$email!=""&$name!="") {
if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)){
$text = base64_encode($text); //检验邮件地址是否合法
$db =mysql_connect("localhost", "****","****");
$time=date("y-m-d");
mysql_select_db("****",$db);
$sql="insert into guest values('','$title','$email','$homepage','$name','$text','','$time')";
$result = mysql_query($sql);mysql_close();
echo "";
}
else
{ echo "邮件地址无效"; echo "返回";} }
else {echo "*必填"; echo "返回";}
//mysql_close($db)
//printf("留言成功按此返回");
?>
--------------------------------111.php---------------------------
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
数据表
create table guest(id int not null auto_increment,primary key(id),title varchar(50),email varchar(30),homepage varchar(30),name varchar(30),text text,relay int,r_time date)
create table relay(id int not null auto_increment,primary key(id),title int,email varchar(30),name varchar(30),text text)
-------------------------index.php--------------------------
网站完全手册
$db =mysql_connect("localhost", "****","****");
mysql_select_db("****",$db);
@$result = mysql_query("SELECT * FROM guest order by id desc",$db);
$i=0;
while($myrow = mysql_fetch_row($result)) {
$guestbook[$i][0] = $myrow[0];
$guestbook[$i][1] = $myrow[1];
$guestbook[$i][2] = $myrow[2];
$guestbook[$i][3] = $myrow[4];
$guestbook[$i][4]=$myrow[6];
$guestbook[$i][5]=$myrow[7];
$i++;
} //读入数组
mysql_close($db) ;
echo "-----------------------------共[";
if ($q!="") {
$page = $q;
} else {
$page = 0;
}
$i=count($guestbook);
$msgnum=20; // 每页20笔
$start = $page * $msgnum;
$end = $start + $msgnum;
if ($end > $i) $end=$i;
$totalpage=$i/$msgnum;
for ($i=0; $i if ($i!=$page) {
echo " $i";
} else {
echo " $i";
}
}
echo "]页-----------------------------
"; printf("");
echo "
";
echo "
主题 | ";电子邮件 | ";呢称 | ";回复 | ";最后回复时间 | ";
"; echo "";echo $guestbook[$i][1]; echo ""; echo " | "; "; echo ""; echo $guestbook[$i][2];echo "";echo " | "; "; echo $guestbook[$i][3]; echo " | "; "; echo $guestbook[$i][4]; echo " | "; "; echo $guestbook[$i][5]; echo " | ";
echo "
";
printf("添加主题");
?>
------------------------------444.php--------------------------------
$db =mysql_connect("localhost", "****","****");
mysql_select_db("****",$db);
@$result = mysql_query("SELECT * FROM guest where id='$id'",$db);
echo "
主题:"; echo $myrow[1]; echo " | "; echo "
"; echo $msg;echo " | ";echo "
主页:"; echo $myrow[3]; echo " |
"; echo "回复列表"; echo " | "; echo "
"; echo "Re:"; echo $myrow[1]; echo " | "; echo "
"; echo $guestbook[$i][2]; echo " | "; echo "
电子邮件:"; echo ""; echo $guestbook[$i][1];echo "";echo " | "; echo "
"; echo $msg; echo " | "; echo "
"; echo "
"; echo "-------------------------------共[";
for ($i=0; $i if ($i!=$page) {
echo " $i";
} else {
echo $i;
}
} echo "]页---------------------------------"; echo "
";
echo "回复";echo "
";
echo "浏览主题";
?>
--------------------------------333.php-----------------------------
if (!$t){
if ($text==""&$email==""&$name==""){echo "*必填";echo "返回"; }
else { if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)){
$text = base64_encode($text); //检验邮件地址是否合法
$db =mysql_connect("localhost", "****","****");
$time=date("y-m-d");
mysql_select_db("****",$db);
$sql="insert into relay values('','$title','$email','$name','$text')";
$result = mysql_query($sql);
$num=$num+1;
$sql="update guest set relay='$num',r_time='$time' where id='$title'";
$result=mysql_query($sql);
mysql_close();
echo "";
}
else { echo "邮件地址无效"; echo "返回";}
} }
else
{ ?> }
?>
-----------------------------------www.php--------------------------
if ($title!=""&$email!=""&$name!="") {
if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)){
$text = base64_encode($text); //检验邮件地址是否合法
$db =mysql_connect("localhost", "****","****");
$time=date("y-m-d");
mysql_select_db("****",$db);
$sql="insert into guest values('','$title','$email','$homepage','$name','$text','','$time')";
$result = mysql_query($sql);mysql_close();
echo "";
}
else
{ echo "邮件地址无效"; echo "返回";} }
else {echo "*必填"; echo "返回";}
//mysql_close($db)
//printf("留言成功按此返回");
?>
--------------------------------111.php---------------------------
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】