我有以下代码,但它不像我想要的那样工作。我只想显示一次表格标题,但现在它每次都重复标题。我希望表格标题是水平的,但现在它是垂直的。
代码:
<?php
include ("core/db_connectie.php");
//file_get_contents("main.tpl.php");
$query = "SELECT * FROM platen";
$result = mysql_query($query) or die (mysql_error());
$table = "<table>";
$cName = "";
$cValue = "";
while($row = mysql_fetch_assoc($result))
{
foreach($row as $columnName=>$columnValue)
{
$cName .= $columnName;
$cValue .= $columnValue;
}
}
$table .= "<tr><th>". $cName ."</th></tr>";
$table .= "<tr><td>". $cValue ."</td></tr>";
$table .= "</table>";
echo $table;
编辑:
我更改了代码,但它现在仍然无法正常工作,它只是将所有内容粘贴在一起
例子:
IDAlbumBandStijlMediumDatumPrijsIDAlbumBandStijlMediumDatumPrijs
1TestTestereRockLP2013-06-1202TestTestereRockLP2013-06-1213