【发布时间】:2018-05-29 04:43:01
【问题描述】:
我想在我的 PHP 文件中将单个数据显示为 2 列作为 mysql 表结果。我已尝试使用我的代码,但相同的数据已显示为类似<tr><td>result1</td><td>result1</td> 的结果。
我已尝试使用我的代码,但结果如下:
| result 1 | result 1 |
| result 2 | result 2 |
| result 3 | result 3 |
| result 4 | result 4 |
| result 5 | result 5 |
| result 6 | result 6 |
| result ... | result ... |
但我需要结果为
| result 1 | result 2 |
| result 3 | result 4 |
| result 5 | result 6 |
| result 7 | result 8 |
| result ... | result ... |
这是我的代码:
<?php
include('config.php');
$data_content = '';
$qry = "SELECT DISTINCT bankName FROM bankData ORDER BY bankName";
$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
{
$data_content.= "<a href='bank/".$row['bank_Name'].".php'> ".$row['bankName']."</a>";
}
mysql_close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<body>
<div>
<table border="1">
<?php
for($i=0; $i<=1; $i++)
{
echo "<tr>";
for($j=0; $j<=1; $j++)
{
echo "<td>";
echo $data_content;
echo "</td>";
}
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
请帮帮我。
【问题讨论】:
-
你的 for 循环没有做任何事情?
标签: php mysql html-table