Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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 将显示拆分为3或4个相等的列_Php - Fatal编程技术网

Php 将显示拆分为3或4个相等的列

Php 将显示拆分为3或4个相等的列,php,Php,我使用PHP和MySQL在一列中显示大约一千个名字的列表 是否有办法修改代码,使数据显示在多个列中,最好高度相等?在这个特定的示例中,三列或四列都可能起作用 这是我的密码 $stm = $pdo->prepare("SELECT P.URL, P.Title, P.Site, P.Live, PB.Common, PB.First, PB.Middle, PB.Last, PB.Prefix, PB.Suffix, PB.Alpha, PB.Born, PB.Died, PB.B

我使用PHP和MySQL在一列中显示大约一千个名字的列表

是否有办法修改代码,使数据显示在多个列中,最好高度相等?在这个特定的示例中,三列或四列都可能起作用

这是我的密码

$stm = $pdo->prepare("SELECT P.URL, P.Title, P.Site, P.Live,
 PB.Common, PB.First, PB.Middle, PB.Last, PB.Prefix, PB.Suffix, PB.Alpha, PB.Born, PB.Died,     PB.Birth_Place, PB.Death_Place, PB.Nationality, ART.URL, ART.Site, ART.Brief, ART.Article
 FROM people P
 LEFT JOIN people_1_bio PB ON PB.URL = P.URL
 LEFT JOIN people_articles ART ON ART.URL = P.URL
 WHERE P.Site = 'PX' AND ART.Site = 'PX' AND ART.Brief !='' AND P.Live = 1
 GROUP BY P.URL ORDER BY P.N");
 $stm->execute(array(
));

while ($row = $stm->fetch())
{
 $URL = $row['URL'];
 $Common = $row['Common'];
 $Article = $row['ART'];
 $Common = $row['Common'];
 $Alpha = $row['Alpha'];
 $Site[] = $row['Site'];
 $List[] = '<a href="#'.$URL.'">'.$row['Common'].'</a>';

 $Roster[] = '<a href="/People/'.$URL.'">'.$Common.'</a><br>';
}

echo '<div style="width: 200px; font-size: 75%; text-align: left; float: left; margin-right:    15px;">';
echo join( $Roster, '' );
echo '</div>';
$stm=$pdo->prepare(“选择P.URL、P.Title、P.Site、P.Live、,
PB.Common、PB.First、PB.Middle、PB.Last、PB.Prefix、PB.Suffix、PB.Alpha、PB.Born、PB.dead、PB.Birth_Place、PB.Death_Place、PB.national、ART.URL、ART.Site、ART.Brief、ART.Article
来自人民党
在PB.URL=P.URL上左键加入人物
LEFT JOIN people\u ART ON ART.URL=P.URL上的文章艺术
其中P.Site='PX'和ART.Site='PX'和ART.Brief!=''和P.Live=1
按P.URL分组(按P.N排序);
$stm->execute(数组)(
));
而($row=$stm->fetch())
{
$URL=$row['URL'];
$Common=$row['Common'];
$Article=$row['ART'];
$Common=$row['Common'];
$Alpha=$row['Alpha'];
$Site[]=$row['Site'];
$List[]='';
$LOSTER[]='
'; } 回声'; 回声加入($花名册,''); 回声';
当然可以,就这样使用吧。下面的示例将数组
$floster
分为3个块:

// Set how many chunks you want to break the array into.
$how_many_chunks = 3;

// Break the '$Roster' array into '$roster_chunks'
$roster_chunks = array_chunk($Roster, $how_many_chunks, true);

// Roll through the '$roster_chunks'
foreach ($roster_chunks as $roster_chunk_key => $roster_chunk_value) {
  echo '<div style="width: 200px; font-size: 75%; text-align: left; float: left; margin-right: 15px;">';
  echo join($roster_chunk_value, '' );
  echo '</div>';
}
//设置要将数组分成多少个块。
$how_number_chunk=3;
//将“$LOSTER”数组拆分为“$LOSTER\u块”
$LOSTER\u chunks=array\u chunk($LOSTER,$how\u numbers\u chunks,true);
//在“$ROUSTER\U块”中滚动
foreach($LOSTS\U chunk作为$LOSTS\U chunk\U key=>$LOSTS\U chunk\U值){
回声';
echo连接($花名册\块\值“”);
回声';
}

当然,您可以设置一些逻辑来确定要将事物分解成多少块。但你的问题和询问并没有说明这一点。这基本上可以归结为您个人的愿望和要求。

是的,可以在更多的栏中显示您的信息。所以这与MySQL无关,是吗?我使用的是PHP和MySQL;我猜解决方案将涉及PHP而不是MySQL,但我真的不知道;我只是觉得提到我正在使用的程序会有所帮助。这个数组块脚本非常好用,只是字母顺序有点奇怪。例如,第一列以爱德华·艾比(Edward Abbey)开始,以亨利·华莱士(Henry Wallace)结束,而第二列以约翰·昆西·亚当斯(John Quincy Adams)开始,以威廉·华莱士(William Wallace)结束。如果第一列只是从第一个值开始,连续运行(例如,以Alan Bateman结束),第二列从第一列停止的地方开始,那就更好了。我原以为我的按条款订货就可以做到这一点,但我错了。虽然脚本很棒,
array\u chunk
的使用与您看到的错误无关。再次测试你的脚本,看看发生了什么。