【发布时间】:2011-08-03 20:01:33
【问题描述】:
您好,我需要从 mySQL 表中构建一个包含两列的表。
这是我现在拥有的:
<table>
<?php
$sql = "SELECT field1, field2 FROM tblX"
$result = mysql_query($sql) or die("\nError Retrieving Records.");
while($row = mysql_fetch_array ($result, MYSQL_ASSOC)){?>
<tr>
<td>
<?=$row['field1']?> - <?=$row['field2']?>
</td>
</tr>
<?php }?>
</table>
这将创建一个像这样的列表:
1
2
3
4
5
我需要表格在这样的两列中:
1 4
2 5
3
如果我该怎么做,这可能吗?
【问题讨论】:
-
您是否尝试相应地在
中添加另一个 对? -
这些问题不清楚。你没有提到,这两个表的转储结果是什么。谁能确定论点,将数据分成两列?
-
因为只有一张表。如果我知道我不会在这里问...
标签: php mysql html algorithm loops