查询结果显示问题 本帖最后由 lazygc520 于 2011-10-14 09:51:51 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库存查询的时候limit了嘛? 这么说吧,假设你查询出了16个结果,如果格式输出,每页只显示8个结果。但是生成页面是带url参数的,会把16个结果都显示出来。这种情况怎么处理? 贴出输出页面代码:<?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>'; }?> 换种方法问吧:假设得到的结果是: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 如何修改php出错页面的颜色? 高手帮忙看一下这个正则有什么错误么? 请问我想用php开发一个小应用,请问基础代码如何写? 页面重写问题 大家来看看为什么网页无法显示--php--在线等 PHP 5.4.13 and PHP 5.3.23 released! 本人急求主页的图片动态转换可链接的原码.那么好心人帮忙啊? [help] php的http上传文件问题 菜鸟问题,页面刷新.. php5.5怎么连接SQLsever 怎么配置 jquery ajax返回二维数组,在线等, 有从.net转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>';
}
?>
假设得到的结果是:
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