时间:2021-07-01 10:21:17 帮助过:17人阅读
$conn = mysql_connect("localhost","root","") or die("Can't connect database: ".mysql_error());
if($conn)
echo "链接成功!";
mysql_select_db("liuyan");
mysql_query("set names 'gbk'");
?>
include("conn.php");
if(isset($_POST['username'])){
$username = $_POST['username'];
$title = $_POST['title'];
$content = $_POST['content'];
$sql = "insert into easy values('$username','$title','$content',now())";
mysql_query($sql) or die("插入失败: ".mysql_error());
}
?>
include("conn.php");
$rowsPerPage = 10;
$row = mysql_fetch_array(mysql_query("select count (*) as c from easy")); //查询总记录数...这点书上看的,不太懂,求解释
$rows = $row['c']; //得到记录数
/*
$a = "select * from easy";
$b = mysql_query($a);
$rows = mysql_num_rows($b);
这个可以么? 另外这个和上面那个有什么区别??
*/
$pages = ceil($rows/$rowsPerPage); //计算页数