本帖最后由 lazygc520 于 2011-10-14 09:51:51 编辑

解决方案 »

  1.   

    数据库存查询的时候limit了嘛?
      

  2.   

    这么说吧,假设你查询出了16个结果,如果格式输出,每页只显示8个结果。但是生成页面是带url参数的,会把16个结果都显示出来。这种情况怎么处理?
      

  3.   

    贴出输出页面代码:<?php
    include('checklogin.php');
    include('conn.php');
    require('inc.php');
    $action = $_GET['action'];
    date_default_timezone_set(PRC);
    $t = 'barcode_2d';
    $date = date("Y-m-d");
    $sql = "select * from `link_rk` where `time`='".$date."'";
    $result = mysql_query($sql,$con) or die(mysql_error());
    $var = mysql_fetch_array($result,MYSQL_NUM);
    $rkno = $var['1'];

    for($i=1;$i<=$HTTP_COOKIE_VARS["queryItemNum"];$i++)
    {
    $where[]= "`packageno`= '".$_GET['qd'.$i]."'";
    }

    $sql2="select * from `".$t."` where ".implode('or',$where)." group by packageno";
    $result = mysql_query($sql2,$con) or die(mysql_error());
    $num_rows2 = mysql_num_rows($result);
    $arr = array();
    while($var = mysql_fetch_array($result,MYSQL_NUM))
    {
    $arr[] = $var;
    }
    // print_r($arr);

    $sql="select * from `".$t."` where ".implode('or',$where)."";
    // echo $sql;
    $result = mysql_query($sql,$con) or die(mysql_error());

    $num_rows = mysql_num_rows($result);

    while($rows = mysql_fetch_array($result,MYSQL_NUM))
    {
    $row2[$rows['2']]++;
    $row3[$rows['3']]++;
    }
    // print_r($row2);
    // print_r($row3);

    $row = array_keys($row3);
    $row1 = array_keys($row2); $total_count = $num_rows2; if($page == '')
    $page = 1;

    $page_size = 1; if( $total_count <= $page_size )
    $page_count = 1;

    if( $total_count % $page_size )
    {
    //如果有余数,则页数等于总数据量除以每页数的结果取整再加一
    $page_count = (int)($total_count / $page_size) + 1;
    }
    else
    {
    $page_count = $total_count / $page_size; //如果没有余数,则页数等于总数据量除以每页数的结果
    }



    $item_start = ($page - 1)*$page_size;

    $sql_page = $sql2." LIMIT ".$item_start.",".$page_size;
    // echo $sql_page; $result = mysql_query($sql_page);
    ?>//输出部分
    <?php
    for($i=1;$i<=$num_rows2;++$i)
    {
    $j= $i-1;
    echo'<tr height="43" style="height: 32.25pt">
    <td height="43" style="height: 32.25pt; font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border: medium none; padding: 0px"> </td>
    <td x:num style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: 1.0pt solid windowtext; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">
    '.$i.'</td>
    <td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">';
    ?>
    <img src="test.php?codebar=BCGcode39extended&text=<?php echo $arr[$j]['2'];?>"></td>
    <?php
    echo'<td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">
    東風日産(中国)</td>
    <td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">
    CVT01</td>
    <td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">';
    ?>
    <img src="test.php?codebar=BCGcode39extended&text=<?php echo $arr[$j]['3'];?>"></td>
    <?php
    echo'<td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">';
    ?>
    <img src="test.php?codebar=BCGcode39extended&text=<?php echo $row2[$row1[$j]];?>"></td>
    <?php
    echo'<td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border-left: medium none; border-right: 1.0pt solid windowtext; border-top: 2.0pt double windowtext; border-bottom: .5pt solid windowtext; padding: 0px">
     </td>
    <td style="font-size: 10.0pt; text-align: center; color: windowtext; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: middle; white-space: nowrap; border: medium none; padding: 0px"> </td>
    </tr>';
    }
    ?>
      

  4.   

    换种方法问吧:
    假设得到的结果是:
    http://127.0.0.1:9090/new/rkyl.php?qb1=packageno&qc1=LIKE&qd1=CVT111011001&qa2=or&qb2=packageno&qc2=LIKE&qd2=CVT111011002&qc3=LIKE&qd3=CVT111011003我是否能通过分页,总共3笔数据,假设每页只显示2行数据:当我点击第一页时,url的结果变成:
    http://127.0.0.1:9090/new/rkyl.php?qb1=packageno&qc1=LIKE&qd1=CVT111011001&qc2=LIKE&qd2=CVT111011002点击第二页时,url的结果变成:
    http://127.0.0.1:9090/new/rkyl.php?qb3=packageno&qc3=LIKE&qd3=CVT111011003