搜索的问题
index.php页面<form id="form1" name="form1" method="get" action="search.php">
input type="text" name="keywords" id="keywords" /> <input type="submit" name="button" id="button" value="搜索" />
</form>
search.php
<?php
$maxnum = 30;
$sql = "select count(news_id) from news where news_title='%$keywords%'";
$rs=$db->query($sql);
$totalRows=$db->fetch_row($rs);
$totalpages = ceil($totalRows/$maxnum);
if(!isset($_GET['page']) || !intval($_GET['page']) || $_GET['page'] > $totalpages)
{
$page = 1; //对3种出错进行默认处理,在url参数page不存在时,page不为10进制数时,page大于可分页数时,默认为1
}else{
$page = $_GET['page'];
}
$fir=($page-1)*$maxnum;
$sql="select * from news where news_title='%$keywords%' order by news_id desc limit $fir,$maxnum";
$rs=$db->query($sql);
$num=$db->num_rows($rs);
if(!$num){?>
这写法错误的,这个条件要怎么写,前面是不是要传值过来??