欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php分页输出问题

程序员文章站 2024-01-11 12:18:58
...
  





这里是 search.php页的
*****************************
这里是searchshow.php 页的
?>

include("conn/conn.php");
include("search.php");

$search=$_POST[search];
$xuanze=$_POST[xuanze];
if($_POST[search]==""){
$search=$_GET[search];
$xuanze=$_GET[xuanze];
}

if(shoptype=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where shoptype='$search' order by mid");
}elseif(user=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where user='$search' order by mid");
}elseif(shopname=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where shopname='$search' order by mid");
}



$minfo=mysql_fetch_array($sql1); //在这里出错
$total=$minfo[total];
$pagesize=5;
if($total $pagecount=1;
}
if(($total%$pagesize)!=0){
$pagecount=intval($total/$pagesize)+1;
}else{
$pagecount=$total/$pagesize;
}
if(($_GET[page])==""){
$page=1;
}else{
$page=intval($_GET[page]);
}


if(shoptype=="$xuanze"){
$sql=mysql_query("select * from tb_members where shoptype='$search' order by mid limit ".($page-1)*$pagesize.",$pagesize");
}elseif(user=="$xuanze"){
$sql=mysql_query("select * from tb_members where user='$search' order by mid limit ".($page-1)*$pagesize.",$pagesize");
}
elseif(shopname=="$xuanze"){
$sql=mysql_query("select * from tb_members where shopname='$search' order by mid limit ".($page-1)*$pagesize.",$pagesize");
}



$info=mysql_fetch_array($sql);//在这里也出错
?>









if($info){
do{ ?>










}while($info=mysql_fetch_array($sql));
?>
帐号 联系人 店铺名称 类型 联系电话 联系地址

共有
echo $total;
?>
条 每页显示 条 第 页/共
if($page>=2){
?>


}
if($pagecount for($i=1;$i ?>

}
}else{
for($i=1;$i ?>






}else{
?>
对不起,您检索的信息不存在!
}mysql_close();

?>


这是出错的地方
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\shihui\admin\searchshow.php on line 33

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\shihui\admin\searchshow.php on line 70


回复讨论(解决方案)

把sql输出来。

说明你的查询失败了,返回的查询结果有问题,打印查询语句分析一下吧

}

if(shoptype=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where shoptype='$search' order by mid");
}elseif(user=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where user='$search' order by mid");
}elseif(shopname=="$xuanze"){
$sql1=mysql_query("select count(*) as total from tb_members where shopname='$search' order by mid");
}
条件出错了,$sql为空,正确如
if($search=="shopname")

相关标签: php分页输出问题