我想从mysql查询中创建一个表 表格应该显示为
pic1 pic2 pic3
name1 name2 name3
-------------------------
pic4 pic5 pic6
name4 name5 name6
请说明如何通过使用php和html来实现?
for ($i = 0; $i < 2; $i++) {
?>
<tr>
<? for ($j = 0; $j < 3; $j++) {
?>
<td>
<table>
<tr>
<td align="left" valign="top"><a href="#"><img src="images/speak-pic.jpg" width="88" height="88"
border="0" class="pic-bod"/></a></td>
</tr>
<tr>
<td align="left" valign="top"><a href="#" class="link-ar"><? echo $t["profile_name"]?> </a>
</td>
</tr>
</table>
</td>
<?
}
?>
</tr>
<?
}
答案 0 :(得分:0)
首先从查询中获取结果并循环它。
// first make the connection..., then
$sql = "SELECT xxxxxx";
$result = mysql_query($sql);
foreach($rs = mysql_fetch_assoc()) {
// put the echo statement here with the apropriate html tags.
}
如果您想深入学习,请从sitepoing.com上获取此链接 http://articles.sitepoint.com/article/php-gallery-system-minutes