【发布时间】:2017-02-26 00:00:03
【问题描述】:
我正在使用 php 查询一个 sql server 数据库并将结果写在屏幕上。我以为我所有的带有 table & tr/td 的 echo 语句都在创建一个表来显示结果,但是当数据显示在屏幕上时,它看起来像下面这样一起运行:
Employee EmployeeIDPrice1Price2Price3Price4Price5
等没有表结构。我应该在此语法中进行哪些更改,以便创建一个实际的表来显示结果?
if ($result = mssql_execute($proc))
{
$number_of_rows = mssql_num_rows($result);
if($number_of_rows > 0) {
echo '<table border="1">';
echo '<tr>';
echo ' <th bgcolor="#FFFFFF" >Employee </th>';
echo ' <th bgcolor="#FFFFFF">EmployeeID </th>';
echo ' <th bgcolor="#FFFFFF">Price1 </th>';
echo ' <th bgcolor="#FFFFFF">Price2 </th>';
echo ' <th bgcolor="#FFFFFF">Price3 </th>';
echo ' <th bgcolor="#FFFFFF">Price4 </th>';
echo ' <th bgcolor="#FFFFFF">Price5 </th>';
echo ' <th bgcolor="#FFFFFF">Price6 </th>';
echo ' <th bgcolor="#FFFFFF">Price7</th>';
echo ' <th bgcolor="#FFFFFF">Price8</th>';
echo ' <th bgcolor="#FFFFFF">Price9</th>';
echo ' <th bgcolor="#FFFFFF">Price10</th>';
echo ' <th bgcolor="#FFFFFF">Price11</th>';
echo '</tr>';
while ($Row = mssql_fetch_assoc($result))
{
echo '<tr><td>'.$Row['Employee'] .
'</td><td>'.$Row['EmployeeID'] .
'</td><td>'."$".round($Row['Price1']) .
'</td><td>'."$".round($Row['Price2']) .
'</td><td>'."$".round($Row['Price3']) .
'</td><td>'."$".round($Row['Price4']) .
'</td><td>'."$".round($Row['Price5']) .
'</td><td>'."$".round($Row['Price6']) .
'</td><td>'."$".round($Row['Price7']) .
'</td><td>'."$".round($Row['Price8']) .
'</td><td>'."$".round($Row['Price9']) .
'</td><td>'."$".round($Row['Price10']) .
'</td><td>'."$".round($Row['Price11']) .
'</td></tr>';
}
echo '</table>';
}
编辑
这就是我的输出的样子,即使在添加了 cellpadding="5" ... 之后,也不是像我在使用 html 单词 table 和 td tr 时所期望的那样明确定义的表格 - 意味着所有数据只是一起流血,而不是像我想象的那样设置表格。
【问题讨论】:
标签: php html joomla html-table joomla3.0