PHP后们怎么添加,每三个图像PHP后添加一个新行(Adding a new row after every three images PHP)...

每三个图像PHP后添加一个新行(Adding a new row after every three images PHP)

我在WordPress中使用高级自定义字段创建了一个图库。 现在我需要添加一个if语句,它将回显一个新的div,并在每三个图像后用行类关闭它。 我试图自己做,但它不起作用。 我哪里错了?

No Content

$images = get_field('gallery_images');

$counter = 3;

?>

if($counter == 3){

echo "

";

$counter = 0;

}

?>

<?php echo $image['alt']; ?>

if($counter == 0){

echo "

";

}

$counter++;

?>

I've created an image gallery using Advanced Custom fields in WordPress. Now I need to add an if statement that will echo a new div and close it with the class of row after every three images. I have attempted to do it myself but it doesn't work. Where am I going wrong?

No Content

$images = get_field('gallery_images');

$counter = 3;

?>

if($counter == 3){

echo "

";

$counter = 0;

}

?>

<?php echo $image['alt']; ?>

if($counter == 0){

echo "

";

}

$counter++;

?>

原文:https://stackoverflow.com/questions/44109653

更新时间:2020-02-15 20:24

最满意答案

你需要逃避报价,因为你正在使用"

更改:

echo "

";

至:

echo "

";

You need to escape the quotation because you are using "

Change:

echo "

";

To:

echo "

";

2017-05-22

相关问答

您没有在数据库中插入图像的名称,而是单词“Array”。 您当前正在将$gravar_imagem01 imagem01插入到imagem01 ,这相当于实际代码中的$_FILES['imagem01'] 。 在imagem01字段中插入$gravar_imagem01['name'] ,因为您想要检索图像的名称,以便稍后使用<?=%24row%5B'imagem01'%5D%20?> 。 注意:由于您不能在SQL查询中使用'$gravar_imagem01['na

...

在这种情况下,它意味着没有任何东西填充$name_image变量。 假设网站目录是本地目录,当你调用image_show函数时,这很可能是你的参数。 它们与您指定的顺序不匹配。 第一个参数应该是名称,第二个参数应该是alt文本,如下所示: function image_show($name_image, $alt_tag)

但是,您将id传递给$name_image ,名称为$alt_tag 。 那应该是它。 In that case it means that there is nothing

...

在$array[]附加到PHP中的数组很简单: $myArray = array(1,2,3);

$myArray[] = 4; //now array(1,2,3,4)

因此,要添加到现有数组,首先要创建新的数组元素 $element = array("item_id" => 1322, "name" => "ITEM_C", /*etc.*/);

然后添加你的数组 $myArray[] = $element;

至于排序,根据您的确切需要,有各种排序功能 。 由于您是根据给定的数组键进

...

尝试删除该行 while($image)

注意这一行 foreach(glob("images/{*.gif,*.jpg,*.png,*.jpeg,*.bmp}", GLOB_BRACE) as $image)

已经在图像上循环,并在目录中没有更多时完成。 我稍微清理了一下代码: <?php

$count = 0;

foreach(glob("images/{*.gif,*.jpg,*.png,*.jpeg,*.bmp}", GLOB_BRACE) as $image)

...

试着用这个 <?php echo'photos'.$row['; ?>

try to use this <?php echo'photos'.$row['; ?>

这是你想要做的。 它一次支持任意数量的行和输出4。 例如,如果有15个项目,则前三行输出4,最后一行输出3。 echo"

$images = array();

$names = array();

while ($row = mysql_fetch_array($content))

{

$images[] = $row['image'];

$names[] = $row['name'];

}

while(!empty($images))

{

...

你需要迭代列而不是表。

include 'mysql.php';

$show_men="SELECT model, id, price,image FROM products WHERE cat='men' ";

$query_men=mysqli_query($conn,$show_men);

while($r

...

你需要逃避报价,因为你正在使用" 更改: echo "

"; 至: echo "
"; You need to escape the quotation because you are using " Change: echo "
"; To: echo "
";
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值