Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中将其余列移动到下一页_Php_Html - Fatal编程技术网

如何在PHP中将其余列移动到下一页

如何在PHP中将其余列移动到下一页,php,html,Php,Html,大家好,我一直在网上搜索,但什么都没有找到。我有生成表的代码。我的问题是,代码显示一页中的所有列,我希望它只显示10列,其余列显示到下一页,如果列仍然超过10列,只显示10个,其余的转到下一页 到目前为止我做了。我的输出如下 第1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 31 | 我需要像这样的东西 条例1 | 2 |

大家好,我一直在网上搜索,但什么都没有找到。我有生成表的代码。我的问题是,代码显示一页中的所有列,我希望它只显示10列,其余列显示到下一页,如果列仍然超过10列,只显示10个,其余的转到下一页 到目前为止我做了。我的输出如下

第1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 31 |

我需要像这样的东西

条例1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

条例11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20

条例21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30

条例31 | 32 | 33 | 34

这是我的密码

   foreach($trips as $key => $element){
   $out .= "<tr>";

    $out .= "<td>$key</td>";
    foreach($element as $subkey => $subelement){

    $out .= "<td >$subelement</td>"; 

    } } $out .= "</tr>";

    }
    $out .= "</table>";
    print $out;   
foreach($key=>$element){
$out.=”;
$out.=“$key”;
foreach($element作为$subkey=>$subelement){
$out.=“$subelement”;
}}$out.=“”;
}
$out.=”;
打印美元;

我终于找到了解决方案,只用php就可以解决这个问题

$tripIds = array_unique($tripIds);
$tripChunks = array_chunk($tripIds,$parameterChunk);

foreach($tripChunks as $tripChunk):

$out = ""; $out .= "<table>";

// td padding for station name
$out .= "<td style='width:123px;padding:0px 15.5px 0px 9.8px;border: 10px solid transparent;     color:red;background-color: #DBDBDB;page-break-inside:avoid; page-break-after:auto;'></td>";


foreach ($tripIds as $keys=>$value):

if(!in_array($value, $tripChunk)) continue;

$out .= "<td style='width:123px;padding:0px 15.5px 0px 9.8px;border: 10px solid transparent; color:red;background-color: #DBDBDB;page-break-inside:avoid; page-break-after:auto;'>$value</td>";
$counter++;

 endforeach;
 $i=0;

foreach ($newArray as $keys=>$value):

$out_temp = "<tr>";

$out_temp .= "<td style='padding:0px 0px 0px 0px;page-break-inside:avoid; page-break-after:auto;'>$keys</td>";
 foreach ($value as $index=>$valu2):

 if(!in_array($index, $tripChunk))
    continue;
 else
 {
    $out .= $out_temp;
    $out_temp = ""; 
 }

 $out .= "<td style='padding:0px 4px 0px 5px;page-break-inside:avoid; page-break-  after:auto;'>$valu2</td>";
 endforeach;

 $out .= "</tr>";
 endforeach;


  $out .= "</table>";
   print $out;

   endforeach; //tripchunk
$tripIds=array\u unique($tripIds);
$tripChunks=array\u chunk($TripID,$parameterChunk);
foreach($tripChunk作为$tripChunk):
$out=“”$出局;
//电台名称的td填充
$out.=”;
foreach($tripIds作为$keys=>$value):
如果(!in_数组($value,$tripChunk))继续;
$out.=“$value”;
$counter++;
endforeach;
$i=0;
foreach($newArray as$keys=>$value):
$out_temp=“”;
$out_temp.=“$keys”;
foreach($index形式的值=>$valu2):
if(!in_数组($index,$tripChunk))
继续;
其他的
{
$out.=$out\u温度;
$out_temp=“”;
}
$out.=“$valu2”;
endforeach;
$out.=”;
endforeach;
$out.=”;
打印美元;
endforeach//三块

您的代码中没有任何地方试图限制这一点?如果数组数据来自数据库,那么您可以在sql查询中使用分页控制和
limit 10 OFFSET##
。这叫做分页。数据来自数组。