如何显示来自mysql数据库的图片,特别是连续两张图片。我在 stack overflow 中阅读了很多文章,所有这些文章都使用 table 标签进行了讨论。但是我找不到任何使用 div 的文章。 这是我的 SQL 代码,它不完全正确。(显示图像,但顺序不正确):
$result=mysql_query("SELECT * FROM images WHERE tag='$tag' ");
while($info=mysql_fetch_array($result))
{
if($count==2) //two images per row
{
print "</div>";
$count = 0;
}
if($count==0)
print '<div class="row"><div class="col-md-6 col-sm-6 gallery-display">';
?>
<figure>
<a href="first-image.php">
<img src="1.jpg" alt="Texture Paper" class="display-image">
</a>
<a href="first-image.php" class="figcaption">
<h3>Texture Paper</h3>
</a>
</figure>
<?php
$count++;
print '</div>';
}
if($count>0)
print "";
?>
这代码应该怎么来!
<div class="row">
<div class="col-md-4 col-sm-4 gallery-display">
<figure>
<a href="first-image.php">
<img src="1.jpg" alt="Texture Paper" class="display-image">
</a>
<a href="first-image.php" class="figcaption">
<h3>Texture Paper</h3>
</a>
</figure>
<!--figure-->
</div>
<div class="col-md-4 col-sm-4 gallery-display">
<figure>
<a href="sec-image.php">
<img src="2..jpg" alt="Photo (:" class="display-image">
</a>
<a href="sec-image.php" class="figcaption">
<h3>Photo Caption</h3>
</a>
</figure>
</div>
<!--.gallery-display-->
<div class="row">
<div class="col-md-4 col-sm-4 gallery-display">
..........loop code continues.......
最佳答案
看起来你想使用 array_chunk .在发布此类内容之前,您可能需要检查一下,因为这似乎与以下内容重复/非常相似
关于php - 使用 Div 显示 MySql 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21635794/