Home >Backend Development >PHP Tutorial >A simple PHP&MYSQL message board source code page 1/2_PHP tutorial
I am new to PHP and spent a few nights writing a message board. Please correct me
p.s. My space does not support PHP and I cannot provide a demonstration T_T
Database structure: (Library name: lyb)
Table 1: admin
field: id(int11) name(varchvr) password(varchvr)
Table 2: lo
field: id(int11) username(varchvr) sex(varchvr) qq(varchvr) email(varchvr) info(text) ip(varchvr) submit_time(datetime)
1 conn.php (connect database file)
mysql_connect("localhost"," root","");//Connect to the database
mysql_select_db("lyb");//Select the database
?>
2 header.php (public header file)
第 [= $row[0] ?>] 条留言
留言人:= $row[1]?> 性别:= $sex ?> 留言时间:= $row[7] ?> if($row[3]) {?> } ?> if($row[4]){ ?> }?> if($_SESSION["key"]==1){ ?> IP:= $row[6] ?> 更改 删除}?>
留言内容:
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if($page==1&&$pages>1)
{
echo "首页 | ";
echo "上一页 | ";
echo "下一页 | ";
echo "尾页 | ";
}
elseif($page>=1&&$page!=$pages&&$num>0)
{
echo "首页 | ";
echo "上一页 | ";
echo "下一页 | ";
echo "尾页 | ";
}
elseif($page==$pages&&$page!=1)
{
echo "首页 | ";
echo "上一页 | ";
echo "下一页 | ";
echo "尾页 | ";
}
elseif($page==$pages)
{
echo "首页 | ";
echo "上一页 | ";
echo "下一页 | ";
echo "尾页 | ";
}
else
{
echo "首页 | ";
echo "上一页 | ";
echo "下一页 | ";
echo "尾页 | ";
}
?>
共 = $pages ?> 页 | 当前第 = $page ?> 页 | 共 =$numrows ?> 条留言