假设行数$total=31,每页只输出8行,$n=ceil($total/8);例中$n为4.正常输出的话:
for($i=1;$i<=$total;++$i)
{
//statement
}
请问是否能格式输出:
第一页 1-8项
第二页 9-16项
第三页 17-24项
第四页 25-31项这样的格式for循环怎么写?
for($i=1;$i<=$total;++$i)
{
//statement
}
请问是否能格式输出:
第一页 1-8项
第二页 9-16项
第三页 17-24项
第四页 25-31项这样的格式for循环怎么写?
$curpageecho "第{$curpage}页".(($curpage-1)*8+1)." - ".$curpage*8 ." 项"<?php
$curpage = 5;echo "第{$curpage}页 ".(($curpage-1)*8+1)." - ".$curpage*8 ." 项";
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);//输出样式
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">
abc</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>';
}
?>