为什么分页和显示结果都正常,但点分页数字的其他页时,却都是显示的“
关键字不能为空!请重新输入关键字”?请高手帮我改一下好吗?(我已试了很多遍,传keyword也试了可能是格式写得不对吧,总是不行,所以请在原件上改好我再试试看,拜托了!)
非常感谢!
<?
$aa=$_GET["action"];
if($aa=="jypx_s")
{
$keyword=trim($_POST["jypx_key"]);
if($keyword==""){
echo "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html;
charset=gb2312'>
<meta http-equiv='refresh' content='2;url=jypx.php'>
<title></title>
</head>
<body>
<table cellspacing='0' cellpadding='0' border='0' height='20%'
width='80%'>
<tr>
<td>
<table width='200' border='0' cellspacing='1' cellpadding='5'
align='center'>
<tr>
<td align='center' bgcolor='#FFFFFF' style='font-family: Tahoma,
Verdana; color: #000000; font-size: 14px;'>关键字不能为空!
<br><br>请<a href='jypx.php'>重新输入关键字!</a></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
exit;
}
$pagesize=5;
$rs=mysql_query("select count(*) FROM dyxx WHERE flid1 = 'jypx'
And content LIKE '%$keyword%'");
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (isset($_GET['page'])){
$page=intval($_GET['page']);
}
else{
$page=1;
}
$offset=$pagesize*($page - 1);
$rs=mysql_query("SELECT * FROM dyxx WHERE flid1='jypx' And content
LIKE '%$keyword%' order by rq desc limit $offset,$pagesize");
if ($myrow = mysql_fetch_array($rs))
{
$i=0;
do {
$id=$myrow['id'];
$i++;
?>
<tr>
<td width="450">※<a class="wb"
href="nr.php?action=bt&id=<?=$id?>"><?=$myrow['title']?></a></td>
<td width="120" align="center"><?=$myrow["rq"]?></td>
</tr>
<?php
}while ($myrow = mysql_fetch_array($rs));
echo "</table>";
}
echo "<div align='center'>共有".$pages."页(".$page."/".$pages.")";
for ($i=1;$i< $page;$i++)
echo "<a href='?action=jypx_s&page=".$i."'>[".$i ."]</a> ";
echo "[".$page."]";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='?action=jypx_s&page=".$i."'>[".$i ."]</a> ";
echo "</div>";
}
?>
补充:上页的FORM是这样的:
<form method="POST" action="jypx_sos.php?action=jypx_s">
name="jypx_key"
(rq:数据库中日期字段)
QQ:125838828
Email:qiangzai.8536@yahoo.com.cn