background image

php 简易留言板程序代码

这是一个最基础的留言板程序了,但是己经有了留言板程序基本功能,很适合于

php 初学

者用用,学习用啊,当然也可以用于企业网站也是很不错的哦。
代码如下
<?php
session_start();
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');
$pagesize = 10;//每一页显示多少留言记录
if(isset($_GET['page'])&&$_GET['page']!='') $page=$_GET['page'];
else $page=0;
$sql = "SELECT a . * , b.name, b.email, b.qq, c.revert_time, c.revert
  FROM post a
  LEFT JOIN revert c ON ( a.id = c.post_id ) , guest b
  WHERE a.guest_id = b.id
  ORDER BY a.id DESC";
$numRecord = mysql_num_rows(mysql_query($sql));
$totalpage = ceil($numRecord/$pagesize);
$recordSql = $sql. " LIMIT ".$page*$pagesize.",".$pagesize;
$result = mysql_query($recordSql);
?>
<!DOCTYPE 

html 

PUBLIC 

"-//W3C//DTD 

XHTML 

1.0 

Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHPiask 简易留言板</title>
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
}
a:link {
 text-decoration: none;
 color: #FF6600;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: underline;