【发布时间】:2021-08-06 10:47:35
【问题描述】:
如果我的起始计数为 0,我如何为每个特定循环(第 4 个)回显一个值? 例如计数为 0,1,2,3,4,6,7,8,9,10,11,12 ,13
我需要它在以下数字上回显/打印:3,8,12,16
这是我的循环代码:
$Num_Rows = mssql_num_rows($query);
$Per_Page = 16; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"]){
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page){
$Num_Pages =1;
} else if(($Num_Rows % $Per_Page)==0) {
$Num_Pages =($Num_Rows/$Per_Page) ;
} else {
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$Page_End = $Per_Page * $Page;
IF ($Page_End > $Num_Rows) {
$Page_End = $Num_Rows;
}
$VALUE = 'last';
echo '<ul>';
for($i=$Page_Start;$i<$Page_End;$i++) {
<li class="<?php if ($pages % 4 == 0) { echo $VALUE; }?>">Test</li>
}
echo '</ul>';
它有点工作,但不幸的是,它开始在 #0
上打印 $VALUE所以它打印在以下计数/数字上:0,4,8,12
而不是正确的:3,8,12,16
【问题讨论】: