0

目前,我正在使用我的一个 SQL 表中的数据创建一个 HTML 表。但是我想为每一列添加标题(注意:我不想使用数据库标题)。我怎样才能做到这一点?以下是我当前没有标题的代码:

<?php
$searchResults = mysql_query("SELECT customerRefId, suburb, postcode, state FROM customer_seeking");
$num_rows = mysql_num_rows($searchResults);
?>
<table border="1">
<?php
while($row=mysql_fetch_array($searchResults))
{
echo"<tr><td>$row[customerRefId]</td><td>$row[suburb]</td><td>$row[postcode]</td><td>$row[state]</td></tr>";
}
?>
</table>
4

3 回答 3

2

嘿,您可以将以下代码用于 header:::

<table border="1">
    <tr><th>customer Ref Id</th><th>suburb</th><th>postcode</th><th>state</th></tr>
    <?php
    while($row=mysql_fetch_array($searchResults))
    {
    echo"<tr><td>$row[customerRefId]</td><td>$row[suburb]</td><td>$row[postcode]</td><td>$row[state]</td></tr>";
    }
    ?>
    </table>
于 2013-06-08T11:33:05.270 回答
0

刚刚添加到表下

<table border="1">
<th>Test</th>
<th>Test2</th>
于 2013-06-08T11:30:37.213 回答
0

while在循环之前输出标题行。

于 2013-06-08T11:31:17.713 回答