<table>
<tr>
<th>image</th>
</tr>
<?php
$query = "SELECT * FROM collage";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><a href="img/collage/<?php echo $row['file'] ?>" target="_blank"><img src="img/collage/<?php echo $row['file'] ?>"></a></td>
</tr>
<?php
}
?>
</table>
你好天才的程序员!
我上面的代码显示如下图像:
答案 0 :(得分:3)
从<tr></tr>
<?php ?>
试试这个
<table>
<tr>
<th>image</th>
</tr>
<tr>
<?php
$query = "SELECT * FROM collage";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{
?>
<td><a href="img/collage/<?php echo $row['file'] ?>" target="_blank"><img src="img/collage/<?php echo $row['file'] ?>"></a></td>
<?php
}
?>
</tr>
</table>
答案 1 :(得分:0)
您当前正在循环表行。您需要一个表格单元格的内部循环才能获得您提到的表格设计。
以下是参考:http://www.w3schools.com/html/html_tables.asp
会是这样的:
<?php
$query = "SELECT * FROM collage";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{
?>
<td><a href="img/collage/<?php echo $row['file'] ?>" target="_blank"><img src="img/collage/<?php echo $row['file'] ?>"></a></td>
<?php
}
?>