日期:2014-05-17 浏览次数:20553 次
<?php
$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'");
?>
<form name = "msgform" method = "post" action = "write.php" enctype = "multipart/form-data" onsubmit = "return checkMessage()">
//javascript略去了
<table width = "64%" border = "0" cellspacing = "1" cellpadding = "3" bgcolor = "#66CCFF" align = "center">
<tr>
<td width = "48%">用 户:
<input type = "txet" name = "username">
</td>
</tr>
<tr>
<td colspan = "2">标 题:
<input type = "text" name = "title" size = "60" maxlength = "50">
</td>
</tr>
<tr>
<td colspan = "2">
<textarea name = "content" rows = "10" cols = "100"></textarea>
</td>
</tr>
<tr>
<td>
<div align = "right">
<input type = "submit" name = "sub" value = "提交">
</div>
</td>
<td>
<input type = "reset" name = "Rewrite" value = "重写">
</td>
</tr>
</table>
</form>
<?php
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());
}
?>
<?php
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);
这个可以