<?
include('conn.php');
include('func.php')
?>
<?
//查询表student
$sql="select * from class1";
mysql_query("set names utf8");
if(empty($_POST[class_name]))
$sql="select * from class1";
else
$sql="select * from class1 where class_name like '%$_POST[class_name]%' && class_name like '%$_POST[class_name]%'";
$re=mysql_query($sql);
//分页显示
$each=5;
$page=onepage($re,$each);
?>
<!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>无标题文档</title>
</head>
<body><table width="600" border="1">
<tr bgcolor="#CCCCCC">
<td height="40" colspan="5" align="center" class="tr1">
<form id="form1" name="form1" method="post" action="">
教室课表查询 输入知行楼教室名称
<label for="08"></label>
<?
?>
<input type="text" name="class_name" />
<input type="submit" name="查询" id="查询" value="查询" />
</form>
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="40" align="center" class="tr1">自动编号</td>
<td height="40" align="center" class="tr1">教室名称</td>
<td height="40" align="center" class="tr1">时间</td>
<td height="40" align="center" class="tr1">课程及教师</td>
<td height="40" align="center" class="tr1">占用班级</td>
</tr> <?
for($i=0;$i<$each;$i++){
if(!($row=mysql_fetch_array($re)))
break;
?>
<tr>
<td height="35" align="center"><? echo($row[id]);?> </td>
<td height="35" align="center"><? echo($row[class_name]);?> </td>
<td height="35" align="center"><? echo($row[class_time]);?> </td>
<td height="35" align="center"><? echo($row[teacher_ke]);?> </td>
<td height="35" align="center"><? echo($row[class_ji]);?> </td>
</tr>
<?
}
?>
<tr>
<td height="35" colspan="5" align="center">
<a href="4.6.php?now=1">首页</a>
<a href="4.6.php?now=<? echo ($page[th]-1)?>">前一页</a>
<a href="4.6.php?now=<? echo ($page[th]+1)?>">后一页</a>
<a href="4.6.php?now=<? echo ($page[pages])?>">末页</a>
当前第<? echo $page[th];?>/<? echo $page[pages];?>页</td>
</tr>
</table>
</body>
</html>
在进行完一次搜索结果过后,如果结果过多进行翻页的话,就会自动跳到全部记录的下一页。。求教这个应该如何解决
include('conn.php');
include('func.php')
?>
<?
//查询表student
$sql="select * from class1";
mysql_query("set names utf8");
if(empty($_POST[class_name]))
$sql="select * from class1";
else
$sql="select * from class1 where class_name like '%$_POST[class_name]%' && class_name like '%$_POST[class_name]%'";
$re=mysql_query($sql);
//分页显示
$each=5;
$page=onepage($re,$each);
?>
<!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>无标题文档</title>
</head>
<body><table width="600" border="1">
<tr bgcolor="#CCCCCC">
<td height="40" colspan="5" align="center" class="tr1">
<form id="form1" name="form1" method="post" action="">
教室课表查询 输入知行楼教室名称
<label for="08"></label>
<?
?>
<input type="text" name="class_name" />
<input type="submit" name="查询" id="查询" value="查询" />
</form>
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="40" align="center" class="tr1">自动编号</td>
<td height="40" align="center" class="tr1">教室名称</td>
<td height="40" align="center" class="tr1">时间</td>
<td height="40" align="center" class="tr1">课程及教师</td>
<td height="40" align="center" class="tr1">占用班级</td>
</tr> <?
for($i=0;$i<$each;$i++){
if(!($row=mysql_fetch_array($re)))
break;
?>
<tr>
<td height="35" align="center"><? echo($row[id]);?> </td>
<td height="35" align="center"><? echo($row[class_name]);?> </td>
<td height="35" align="center"><? echo($row[class_time]);?> </td>
<td height="35" align="center"><? echo($row[teacher_ke]);?> </td>
<td height="35" align="center"><? echo($row[class_ji]);?> </td>
</tr>
<?
}
?>
<tr>
<td height="35" colspan="5" align="center">
<a href="4.6.php?now=1">首页</a>
<a href="4.6.php?now=<? echo ($page[th]-1)?>">前一页</a>
<a href="4.6.php?now=<? echo ($page[th]+1)?>">后一页</a>
<a href="4.6.php?now=<? echo ($page[pages])?>">末页</a>
当前第<? echo $page[th];?>/<? echo $page[pages];?>页</td>
</tr>
</table>
</body>
</html>
在进行完一次搜索结果过后,如果结果过多进行翻页的话,就会自动跳到全部记录的下一页。。求教这个应该如何解决
<a href="4.6.php?now=<? echo ($page[th]-1)?>">前一页</a>
<a href="4.6.php?now=<? echo ($page[th]+1)?>">后一页</a>
<a href="4.6.php?now=<? echo ($page[pages])?>">末页</a>
在你的翻页连接中,都没有传递过滤条件
自然就不会按条件查询了