首页上一页 1 下一页尾页 1 条记录 1/1页
PHP代码出错
发表在PHP图书答疑
2009-11-05
是否精华
是
否
版块置顶:
是
否
<?php
02 $action=$_GET["action"];
03 $namekey=$_GET["namekey"];
04
05 if ($page==""){
06 $page=1;}
07 if (is_numeric($page)){
08 $page_size=4;
09 if($action=="all"){ //每页显示4条记录
10 $query="select count(*) as total from shop_user";
11 $result=mysql_query($query); }
12 elseif($action=="huiyuan"){
13 $query="select count(*) as total from shop_user where reglx =1";
14 $result=mysql_query($query);
15 }
16 elseif($action=="vip"){
17 $query="select count(*) as total from shop_user where reglx =2";
18 $result=mysql_query($query);
19 }
20 elseif($action=="select"){
21 $query="select count(*) as total from shop_user where UserName like '%$namekey%'";
22 $result=mysql_query($query);
23 }
24 else{
25 $query="select count(*) as total from shop_user";
26 $result=mysql_query($query);
27 } //查询符合条件的记录总条数
28 $message_count=mysql_result($result,0,"total"); //要显示的总记录数
29 $page_count=ceil($message_count/$page_size); //根据记录总数除以每页显示的记录数求出所分的页数
30 $offset=($page-1)*$page_size;
31 //计算下一页从第几条数据开始循环
32 if($action=="$action"){
33 $sql=mysql_query("select * from shop_user limit $offset, $page_size");
34 $row=mysql_fetch_object($sql);
35 }
36 elseif($action=="$huiyuan"){
37 $sql=mysql_query("select * from shop_user where reglx =1 limit $offset, $page_size");
38
39 $row=mysql_fetch_object($sql);
40 }
41 elseif($action=="$vip"){
42 $sql=mysql_query("select * from shop_user where reglx =2 limit $offset, $page_size");
43
44 $row=mysql_fetch_object($sql);
45 }
46 elseif($action=="$select"){
47 $sql=mysql_query("select * from shop_user where UserName like '%$namekey%' limit $offset, $page_size");
48
49 $row=mysql_fetch_object($sql);
50 }
51 else{
52 $sql=mysql_query("select * from shop_user limit $offset, $page_size");
53 $row=mysql_fetch_object($sql);
54 }
55 if(!$row){
56 echo "<font color='red'>暂无公告信息!</font>";
57 }
58 do{
59 ?>
02 $action=$_GET["action"];
03 $namekey=$_GET["namekey"];
04
05 if ($page==""){
06 $page=1;}
07 if (is_numeric($page)){
08 $page_size=4;
09 if($action=="all"){ //每页显示4条记录
10 $query="select count(*) as total from shop_user";
11 $result=mysql_query($query); }
12 elseif($action=="huiyuan"){
13 $query="select count(*) as total from shop_user where reglx =1";
14 $result=mysql_query($query);
15 }
16 elseif($action=="vip"){
17 $query="select count(*) as total from shop_user where reglx =2";
18 $result=mysql_query($query);
19 }
20 elseif($action=="select"){
21 $query="select count(*) as total from shop_user where UserName like '%$namekey%'";
22 $result=mysql_query($query);
23 }
24 else{
25 $query="select count(*) as total from shop_user";
26 $result=mysql_query($query);
27 } //查询符合条件的记录总条数
28 $message_count=mysql_result($result,0,"total"); //要显示的总记录数
29 $page_count=ceil($message_count/$page_size); //根据记录总数除以每页显示的记录数求出所分的页数
30 $offset=($page-1)*$page_size;
31 //计算下一页从第几条数据开始循环
32 if($action=="$action"){
33 $sql=mysql_query("select * from shop_user limit $offset, $page_size");
34 $row=mysql_fetch_object($sql);
35 }
36 elseif($action=="$huiyuan"){
37 $sql=mysql_query("select * from shop_user where reglx =1 limit $offset, $page_size");
38
39 $row=mysql_fetch_object($sql);
40 }
41 elseif($action=="$vip"){
42 $sql=mysql_query("select * from shop_user where reglx =2 limit $offset, $page_size");
43
44 $row=mysql_fetch_object($sql);
45 }
46 elseif($action=="$select"){
47 $sql=mysql_query("select * from shop_user where UserName like '%$namekey%' limit $offset, $page_size");
48
49 $row=mysql_fetch_object($sql);
50 }
51 else{
52 $sql=mysql_query("select * from shop_user limit $offset, $page_size");
53 $row=mysql_fetch_object($sql);
54 }
55 if(!$row){
56 echo "<font color='red'>暂无公告信息!</font>";
57 }
58 do{
59 ?>