【发布时间】:2013-03-28 02:07:54
【问题描述】:
我无法将它放到一张桌子上。现在我正在使用两张桌子并将它们并排放置,但我认为这不是最好的解决方案。我已经把桌子都摆好了,我只是不知道怎么把它变成一张桌子。
while ($row = mysql_fetch_assoc($query)) {
$result .= "<tr> <td> {$row['a']} the {$row['b']} </td> </tr>";
}
echo $thegames;
这会产生类似:
james the giant
rick the monster
chris the goblin
我想要的是能够从单独的 while 循环中添加更多 tds...
while($secondrow = mysql_fetch_assoc($secondquery)) {
$first = "<td> {$secondrow['alias']} </td>";
$second = "<td> {$secondrow['number']} </td>";
}
所以最后我希望它看起来像这样:
james the giant $secondrow['alias'] $secondrow['number']
rick the monster $secondrow['alias'] $secondrow['number']
等等……
希望这是有道理的。我现在正在做的是创建两个单独的表并尝试将它们排列起来,但不喜欢这种方法。任何帮助都会很棒。
【问题讨论】:
-
Please, don't use
mysql_*functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解 prepared statements,并使用 PDO 或 MySQLi - this article 将帮助您决定哪个。
标签: php while-loop html-table