我有一个关于五月数据库的选择查询
while($row=mysql_fetch_assoc(mysql_query("select * from items"))){
//here
}
我希望它显示网格样式,我使用
while($row=mysql_fetch_assoc(mysql_query("select * from "))){
?>
<tr>
<td><img src="<?php echo $row['path']?>"></td>
</tr>
<tr>
<td><?php echo $row['name'] ?></td>
</tr>
<?php
}
但它将显示垂直样式,我将使用什么html标签,我也使用<span>
,但我无法正确显示
在这种情况下,将行的输出包装在函数中要好得多。Smth如下:
function showRow($row) {
?>
<tr>
<td><img src="<?php echo $row['path']?>"></td>
<td><?php echo $row['name'] ?></td>
</tr>
<?
}
然后:
<table>
<?
while($row=mysql_fetch_assoc(mysql_query("select * from "))){
showRow($row);
}
?>
</table>