我有一张像
这样的表格id course activities
1 Microbiology Quiz1
2 Microbiology Quiz2
3 Microbiology Quiz3
4 Microbiology Quiz4
我需要在php文件中显示为表头
Quiz1 Quiz2 Quiz3 Quiz3 Quiz4
这是我的代码
<?php
$sql = mysql_query('SELECT * FROM activity');
while($row = mysql_fetch($sql))
{
$activities $row['activities'];
}
echo '<table>
<tr>
<th>'.$activities.'</th>
</tr>
</table>';
?>
答案 0 :(得分:1)
您只需重新组织代码:
<?php
$sql = mysql_query('SELECT * FROM activity');
echo '<table><tr>';
while($row = mysql_fetch_array($sql))
{
echo '<th>'.$row['activities'].'</th>';
}
echo '</tr>';
//your data rows here
echo '</table>';
?>