Php 每隔一段时间中断长回显数组内容
我需要你帮我写剧本。。我试图将查询的一些内容回显到一个html表中,但我想在每个第7个参数处打断它。下面的脚本只中断前七个,而其余的脚本并没有按时间间隔中断,它们也被从html表中回显出来 请问我怎么做。谢谢你的时间和帮助Php 每隔一段时间中断长回显数组内容,php,html,css,arrays,Php,Html,Css,Arrays,我需要你帮我写剧本。。我试图将查询的一些内容回显到一个html表中,但我想在每个第7个参数处打断它。下面的脚本只中断前七个,而其余的脚本并没有按时间间隔中断,它们也被从html表中回显出来 请问我怎么做。谢谢你的时间和帮助 echo "<table class=\"altrowstable\" bgcolor = gold >\n"; $count = 0; echo "<tr align= \"center\">\n"; $carry_over = array();
echo "<table class=\"altrowstable\" bgcolor = gold >\n";
$count = 0;
echo "<tr align= \"center\">\n";
$carry_over = array();
$score_count = mysql_numrows($query8);
echo "<td>" . "Failed: ";
if ($score_count !== 0) {
while ($row8 = mysql_fetch_assoc($query8)) {
echo "<th>" . $row8['course_code'] . "</th>";
if ($count == 7) {
echo "</tr>\n";
echo "</table>";
}
}
}
echo“\n”;
$count=0;
回音“\n”;
$carry_over=数组();
$score\u count=mysql\u numrows($query8);
“回声”。“失败:”;
如果($score\u count!==0){
while($row8=mysql\u fetch\u assoc($query8)){
回显“$row8[“课程代码]”;
如果($count==7){
回音“\n”;
回声“;
}
}
}
您需要使用模数运算符%
,它返回除法后的余数<代码>$count%7==0表示当前计数是7的倍数,您应该中断。您还需要增加$count
echo "<table class=\"altrowstable\" bgcolor = gold >\n";
$count = 0;
echo "<tr align= \"center\">\n";
$carry_over = array();
$score_count = mysql_numrows($query8);
echo "<td>"."Failed: ";
if($score_count !== 0){
while ($row8 = mysql_fetch_assoc($query8)) {
echo "<th>".$row8['course_code']."</th>";
// Increment $coutn
$count++;
// Check the modulus
if ( $count % 7 == 0 ){
echo "</tr>\n";
echo "</table>";
}
}
}
echo“\n”;
$count=0;
回音“\n”;
$carry_over=数组();
$score\u count=mysql\u numrows($query8);
回显“.”失败:;
如果($score\u count!==0){
而($row8=mysql\u fetch\u assoc($query8)){
回显“$row8[“课程代码]”;
//增量$coutn
$count++;
//检查模数
如果($count%7==0){
回音“\n”;
回声“;
}
}
}
使用模运算符而不是等式
if ( ($count+1) % 7 ){
+1在那里,因此它不会在$count==0时立即中断,因为0%n
是0