首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SQL查询带有标题的create table

问SQL查询带有标题的create table
EN

Stack Overflow用户
提问于 2013-06-08 19:24:29
回答 3查看 298关注 0票数 0

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

代码语言:javascript
复制
<?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>
EN

回答 3

Stack Overflow用户

发布于 2013-06-08 19:33:05

嘿,你可以使用下面的代码来标头:

代码语言:javascript
复制
<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>
票数 2
EN

Stack Overflow用户

发布于 2013-06-08 19:30:37

刚添加到表下

代码语言:javascript
复制
<table border="1">
<th>Test</th>
<th>Test2</th>
票数 0
EN

Stack Overflow用户

发布于 2013-06-08 19:31:18

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16999030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档