PHP - 尝试在新行上显示Mysql结果

时间:2017-08-07 04:27:07

标签: php

试图找出如何使它成为结果停止显示为一个整体行,而是每个都在他们自己的行上。到目前为止没有太多运气。

$result = mysql_query("SELECT *, ROUND(score) AS performance FROM images ORDER BY ROUND(score) DESC LIMIT 11,50");
while($row = mysql_fetch_object($result)) {
    $top_ratings2[] = (object) $row;
}


<? foreach($top_ratings2 as $key => $image) : ?>
<td valign="top">
  <b><?=$image->name?></b>
  <b>Score:</b> <?=$image->score?>
  <b>Wins:</b> <?=$image->wins?> 
</td>
<? endforeach ?>

1 个答案:

答案 0 :(得分:0)

尝试使用表格

<?php
$result = mysql_query("SELECT *, ROUND(score) AS performance FROM images ORDER BY ROUND(score) DESC LIMIT 11,50");
while ($row = mysql_fetch_object($result)) {
    $top_ratings2[] = (object)$row;
}
?>
<table>
    <thead>
    <tr>
        <td>Name</td>
        <td>Score</td>
        <td>Wins</td>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($top_ratings2 as $key => $image) : ?>
        <tr>
            <td valign="top">
                <?= $image->name ?>
            </td>
            <td valign="top">
                <?= $image->score ?>
            </td>
            <td valign="top">
                <?= $image->wins ?>
            </td>
        </tr>
    <?php endforeach ?>
    </tbody>
</table>