此图像编辑器对php foreach循环进行分页
通过foreach分页php提供帮助 我有以下代码:此图像编辑器对php foreach循环进行分页,php,foreach,pagination,Php,Foreach,Pagination,通过foreach分页php提供帮助 我有以下代码: /*loop trough folders and show images from each folder*/ foreach ($folders as $folderNames2) { ?> <div class="sEditorEffectsSampleImages" id="<?php echo $folderNames2; ?>List"> <?php //list image
/*loop trough folders and show images from each folder*/
foreach ($folders as $folderNames2) {
?>
<div class="sEditorEffectsSampleImages" id="<?php echo $folderNames2; ?>List">
<?php
//list images from each folder
/*search .png files in each folder andd create effect list form png names*/
$files = glob($settingsValue['effectsFolder'] . '/' . $folderNames2 . '/*.png');
/*if there is images in folder list them*/
if (count($files > 0)){
?>
<?php
/*loop trough each folder and outpu image names*/
foreach ($files as $name) {
$path = explode('/', $name);
$name = explode('.', $path[2]);
//echo '<li id="'.$name[0].'" idf="'.$folderNames.'"><a href="#">'.$name[0].'</a></li>';
//echo $name[0]."|";
?>
<div class="imageEffectSampleImageHodlder" sEffect="<?php echo $name[0]; ?>"
sEffectCategory="<?php echo $folderNames2; ?>"><img
src="<?php echo $settingsValue['effectsFolder'] . '/' . $folderNames2 . '/' . $name[0] . '.png'; ?>"/>
<p> <?php echo $name[0]; ?></p></div>
<?php
}/*for each image loop*/
?>
<?php
}/*if count $files is bigger then zero*/
?>
/*循环文件夹并显示每个文件夹中的图像*/
foreach($folderNames2形式的文件夹){
?>
通常,使用分页时,您需要使用$\u GET来确定在某个页面上显示什么内容。它可以是简单的,也可以是复杂的,您需要这样做
如果阵列中的所有内容都已存在,则可以按如下方式完成:
$i = 0; //current image
$start = $_GET['start']; //number to start on
$max = 5; //number per page
foreach ($images as $img) {
if ($start > $i) continue;
if ($i > ($start + $max)) break;
echo "<img src='{$img}' />";
}
$i=0;//当前图像
$start=$\u GET['start'];//开始的编号
$max=5;//每页的数量
foreach($img形式的图像){
如果($start>$i)继续;
如果($i>($start+$max))中断;
回声“;
}
然后,您需要绘制页码链接
for ($i = 0; $i <= (len($array) / $max); $i++) {
echo "<a href='./thispage.php?start=" . ($i * $max) . "'>{$i}</a>";
}
for($i=0;$i不使用我的代码foreach($name)文件{$path=explode('/',$name);$name=explode('.',$path[2]);//echo';//echo$name[0]。“|”?>到底什么是“不起作用的”?你是直接复制粘贴我的代码到你的代码中,还是你使用了这个想法并对它进行了编辑来使用你的设置?没有复制来发布我有什么功能代码$i=0;foreach($files as$name){if($i==6){break;}$path=explode('/',$name);$name=explode('.',$path[2]);//echo'”;//echo$name[0]”|“;$i++;//Zähler um 1 erhöhen?>如何生成自动调整站点的链接:>请将您的代码发布到原始帖子,以便其清晰易读!对于>,您需要确定您所在的页面,并相应地链接到下一页或上一页。$page=($start/$max)下一页的
和上一页的