<div class="neirong-sousuo-right"><img src="image/fdj.gif" align="absmiddle"/> 搜索关键字:<input name="key" type="text" id="key" /><a href="#"><img src="image/sousuo.gif" align="absmiddle" onClick="cx();" border="none;"/></a></div>
<?php
include('MySQL.php');//调用
include'session.php';
$objMySQL=new MySQL();
$key=$_GET['key']; //中点在这, 如果把get 改成post 之后该怎么写
$pageNumber=$_GET['pageNumber'];
$pageSize=6;//每页显示几条
if($pageNumber==null){
$pageNumber=1;
}
if($key==""){// all tb_res
$sql = "select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id order by n_res_id desc limit ".(($pageNumber-1)*$pageSize).",$pageSize";
//$sql="select * from tb_res order by n_res_id desc limit ".(($pageNumber-1)*$pageSize).",$pageSize";
$sqlcount="SELECT count( * )FROM tb_cat c, tb_res r WHERE c.n_cat_id = r.n_cat_id order by n_res_id desc";
}else{
// $sql="select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%' limit ".(($pageNumber-1)*$pageSize).",$pageSize";
$sql="select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%' limit ".(($pageNumber-1)*$pageSize).",".$pageSize;
echo $sql;
$sqlcount="SELECT count( * )FROM tb_cat c, tb_res r WHERE c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%'";
}
echo $sqlcount;
$count=$objMySQL->query($sqlcount);
$fetch=mysql_fetch_row($count);
$total=$fetch[0];
$total=ceil($total/$pageSize);//总页数=共有多少页/每页显示多少条数据\
//echo $total;
$re=$objMySQL->query($sql);
if($row=mysql_num_rows($re)){
while($result=mysql_fetch_assoc($re))
{
?>
<tr align="center">
<td height="32"><input name="n_cat_id" type="hidden" value="<?php echo $result['n_cat_id'];?>"/><?php echo $result['v_cat_name'];?></td>
<td height="32"><a href="<?php
if ($result['v_image_url'] == null || strlen($result['v_image_url']) < 1){
echo "../images/null.gif";
}else{
echo $result['v_image_url'];
}
?>" id=<?php echo $result['n_res_id'];?>>点击查看</a></td>
<td><?php echo $result['v_res_url'];?></td>
<td><?php echo $result['v_title'];?></td>
<td><?php echo $result['n_length'];?></td>
<td><?php echo $result['v_director'];?></td>
<td><?php echo mb_substr($result['v_desc'],0,27,"utf-8");?></td>
<td><?php echo $result['n_chapters'];?></td>
<td><?php echo $result['v_from'];?></td>
<td><a href="update_source.php?id=<?php echo $result['n_res_id'];?>">修改</a> <a href="#" onclick="deletes(<?php echo $result['n_res_id']?>)">删除</a></td>
</tr>
<?php }
}
else{ ?>
<div style="float:left; color:red;">对不起,没有找到数据</div>
<?php }?>
</table>
</div><div class="neirong-fanye">
<?php
if($pageNumber==1)
{
?>
首页<?php }else{?>
<a href="resources.php">首页</a>
<?php }?>
<?php
if($pageNumber < $total){
}
?>
下一页
<?PHP }else{ ?>
<a href="resources.php?pageNumber=<?php echo $pageNumber+1?>">上一页</a>
<?php }?>
<?php
if($pageNumber==1)
{
?>
上一页<?php }else{?>
<a href="resources.php?pageNumber=<?php echo $pageNumber-1?>">上一页</a>
<?php }?>
<?php
if($pageNumber==$total)
{
?>
尾页<?php }else{?>
<a href="resources.php?pageNumber=<?php echo $total?>">尾页</a>
<?php }?>获取到搜索关键字之后因为只能用get传值 但是如果必须用post传得话 这个代码应该怎么改
<?php
include('MySQL.php');//调用
include'session.php';
$objMySQL=new MySQL();
$key=$_GET['key']; //中点在这, 如果把get 改成post 之后该怎么写
$pageNumber=$_GET['pageNumber'];
$pageSize=6;//每页显示几条
if($pageNumber==null){
$pageNumber=1;
}
if($key==""){// all tb_res
$sql = "select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id order by n_res_id desc limit ".(($pageNumber-1)*$pageSize).",$pageSize";
//$sql="select * from tb_res order by n_res_id desc limit ".(($pageNumber-1)*$pageSize).",$pageSize";
$sqlcount="SELECT count( * )FROM tb_cat c, tb_res r WHERE c.n_cat_id = r.n_cat_id order by n_res_id desc";
}else{
// $sql="select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%' limit ".(($pageNumber-1)*$pageSize).",$pageSize";
$sql="select c.v_cat_name,r.* from tb_cat c,tb_res r where c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%' limit ".(($pageNumber-1)*$pageSize).",".$pageSize;
echo $sql;
$sqlcount="SELECT count( * )FROM tb_cat c, tb_res r WHERE c.n_cat_id = r.n_cat_id and r.v_title like '%".$key."%'";
}
echo $sqlcount;
$count=$objMySQL->query($sqlcount);
$fetch=mysql_fetch_row($count);
$total=$fetch[0];
$total=ceil($total/$pageSize);//总页数=共有多少页/每页显示多少条数据\
//echo $total;
$re=$objMySQL->query($sql);
if($row=mysql_num_rows($re)){
while($result=mysql_fetch_assoc($re))
{
?>
<tr align="center">
<td height="32"><input name="n_cat_id" type="hidden" value="<?php echo $result['n_cat_id'];?>"/><?php echo $result['v_cat_name'];?></td>
<td height="32"><a href="<?php
if ($result['v_image_url'] == null || strlen($result['v_image_url']) < 1){
echo "../images/null.gif";
}else{
echo $result['v_image_url'];
}
?>" id=<?php echo $result['n_res_id'];?>>点击查看</a></td>
<td><?php echo $result['v_res_url'];?></td>
<td><?php echo $result['v_title'];?></td>
<td><?php echo $result['n_length'];?></td>
<td><?php echo $result['v_director'];?></td>
<td><?php echo mb_substr($result['v_desc'],0,27,"utf-8");?></td>
<td><?php echo $result['n_chapters'];?></td>
<td><?php echo $result['v_from'];?></td>
<td><a href="update_source.php?id=<?php echo $result['n_res_id'];?>">修改</a> <a href="#" onclick="deletes(<?php echo $result['n_res_id']?>)">删除</a></td>
</tr>
<?php }
}
else{ ?>
<div style="float:left; color:red;">对不起,没有找到数据</div>
<?php }?>
</table>
</div><div class="neirong-fanye">
<?php
if($pageNumber==1)
{
?>
首页<?php }else{?>
<a href="resources.php">首页</a>
<?php }?>
<?php
if($pageNumber < $total){
}
?>
下一页
<?PHP }else{ ?>
<a href="resources.php?pageNumber=<?php echo $pageNumber+1?>">上一页</a>
<?php }?>
<?php
if($pageNumber==1)
{
?>
上一页<?php }else{?>
<a href="resources.php?pageNumber=<?php echo $pageNumber-1?>">上一页</a>
<?php }?>
<?php
if($pageNumber==$total)
{
?>
尾页<?php }else{?>
<a href="resources.php?pageNumber=<?php echo $total?>">尾页</a>
<?php }?>获取到搜索关键字之后因为只能用get传值 但是如果必须用post传得话 这个代码应该怎么改
解决方案 »
- 因跨网站,我把 php.ini 中的 session.cookie_domain=.aaa.com
- 跳转页面后session不能保存,急啊!!!那位达人指点一下啊
- Warning: session_module_name() [function.session-module-name]: A session is acti
- 数组的问题
- 求大大们支招啊 如何让sql读出来的数据按数字排列
- 急啊,帮帮忙啊MySQL server error report:Array
- 函数exec(),system()等怎么执行不了
- 这个问题怎么解决啊!
- 出错了呀!快快来看看呀
- 关于购物车中某单个物品的id传递问题
- 实际项目中有用 zend framework的吗
- 这是什么域名?
[/QUOTE]用post传也很简单啊。你只要把写个form
<form method="post" action="aaa.php">
<input type="text" name="key" />
</form>
把form的action换成你处理数据的action,然后就可以在处理数据的代码中使用
$key=$_POST['key'];了
用post传也很简单啊。你只要把写个form
<form method="post" action="aaa.php">
<input type="text" name="key" />
</form>
把form的action换成你处理数据的action,然后就可以在处理数据的代码中使用
$key=$_POST['key'];了