繁体   English   中英

SQL查询创建带有标题的表

[英]SQL query create table with headings

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

<?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>

嘿你可以使用以下代码标题:::

<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>

刚刚在表格下添加

<table border="1">
<th>Test</th>
<th>Test2</th>

while循环之前输出标题行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM