<?php
$conn=mysql_connect('localhost','root','admin') or die('could not connect: '.mysql_error());
mysql_select_db('sybgtjxt') or die('could not select database');
mysql_query("set names gbk" );
if(mysqli_connect_errno()){
echo"數據庫連接失敗";
}
else{
$pagesize=5;
if($_GET['page']!='')
$page=$_GET['page'];
else {
$page=1;
}
$sql1="select * from tblreport where is_modify=0 order by sid desc";
$rs=mysql_query($sql1);
$numRecord=mysql_num_rows($rs);
//echo"$numRecord";
//echo "$page";
$totalpage=ceil($numRecord/$pagesize);
//echo"$totalpage";
$recordSql=$sql1." limit ".(($page-1)*$pagesize).",".$pagesize;
$result=mysql_query($recordSql);
//if($result)
//echo"成功";
// else
//echo "失敗";
//$rst=mysql_fetch_array($rs);
//echo $rst['pname'];
}
?>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#fcc898"
style="height: 25px">
<tr>
<td width="3%" bgcolor="#FCEBE3" style="height: 16px">
<img src="../images/xiaotu.jpg" /> <font style="font-size: 14px">作業評分>>批改作業</font>
</td>
</tr>
</table>
<table>
<tr>
<td>
學生姓名:
</td>
<td style="width: 83px">
<input name="sname" type="text" id="sname" style="border-style:Groove;width:120px;" />
</td>
<td>
<input type="submit" name="Append" value="查詢" id="Append" class="redButtonCss" />
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr style="line-height: 27px">
<td align="center" colspan="2">
<div id="Panel1" style="width:100%;text-align:right;">
<div>
<?php
while($rst=mysql_fetch_array($result)){
?>
<table cellspacing="0" cellpadding="0" rules="all" border="1" id="gridview" style="color:#333333;border-color:#FCC898;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
<tr class="TrCss" align="center" style="background-color:#ECE8E9;font-weight:normal;height:27px;">
<th scope="col" style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;height:27px;width:80px;">學生編號</th>
<th scope="col" style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;height:27px;width:200px;">報告名稱</th>
<th scope="col" style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;height:27px;">任課老師</th>
<th scope="col" style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;height:27px;">學生姓名</th>
<th scope="col" style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;height:27px;width:100px;">操作</th>
</tr><tr align="center" style="color:#333333;background-color:White;border-color:#FCC898;border-width:1px;border-style:solid;">
<td style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;width:80px;">
<!--學生編號--><?php
$sql2="select * from tblstudent where sid='$rst[sid]'";
$re_s2=mysql_query($sql2);
$rst_s2=mysql_fetch_array($re_s2);
echo $rst['sid']?>
</td><td style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;width:200px;">
<!--報告名稱--><?php echo $rst['pname']?>
</a>
</td><td style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;">
<!--老師名字--><?php echo $rst['tname']?>
</td><td style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;">
<!--姓名--><?php echo $rst_s2['sname']?>
</td><td style="border-color:#FCC898;border-width:1px;border-style:solid;font-weight:normal;width:100px;">
<a href="Pigai.#">批改</a>
<br />
</td>
</tr>
</table>
</div>
<?php
}
?>
</div>
<!-- 頁碼結束-->
建議你在提交數據給數據庫前做個斷點,輸出一下你的sql語句,這樣可以驗證一下你的sql語句是否有錯了。
$rs=mysql_query($sql1);
$numRecord=mysql_num_rows($rs);
$totalpage=ceil($numRecord/$pagesize);
$recordSql=$sql1." limit ".(($page-1)*$pagesize).",".$pagesize;
echo $recordSql; //這裡看看你浏覽器點擊第二頁時的sql拼裝是否有問題。
//$result=mysql_query($recordSql);