3
我正在使用php從數據庫(SQL Server 2012)生成動態表。使用下面的代碼粘貼:從SQL Server 2012和PHP填充動態表中的額外行
<table class="table table-bordered" id="tb">
<tr style="BACKGROUND-COLOR: DarkGrey ">
<th colspan="4" style="text-align:Center;">Objectives and Targets </th>
</tr>
<tr class="tr-header">
<th>Objectives/Measures</th>
<th colspan="2">Targets/Achievements/Timelines</th>
<th style="text-align:Center;width:1%;" rowspan="2">Weightage %</th>
</tr>
<tr>
<th> </th>
<th> </th>
<th style="width:10%;"> Date </th>
</tr>
<tbody>
<?PHP
$myquery=" select replace(Objectives, '||<==', '') as Objectives, replace(Targets, '==', '') as Targets, replace(Weightage, '==', '') as Weightage, Corporate_Objective, Corporate_Objective_Weightage from Appraisal_Objectives WHERE Serial_Number='$Serial_Number' ORDER BY Row_Number asc";
$fetched=sqlsrv_query($conn,$myquery) ;
if($fetched === false) { die(print_r(sqlsrv_errors(), true));}
while($res=sqlsrv_fetch_array($fetched,SQLSRV_FETCH_ASSOC))
{
$Corporate_Objective=$res['Corporate_Objective'];
$Weightage=$res['Weightage'];
$Objectives=$res['Objectives'];
$Targets=$res['Targets'];
$Corporate_Objective_Weightage=$res['Corporate_Objective_Weightage'];
echo "<tr><td>".$Corporate_Objective."</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td><b>".$Corporate_Objective_Weightage."</b></td></tr>";
echo "<tr><td>".$Objectives."</td>";
echo "<td>".$Targets."</td>";
echo "<td></td>";
echo "<td>".$Weightage."</td></tr>";
}
?>
</tbody>
</table>
問題
輸出創造其間的每一行許多不需要的空白行!我沒有在代碼中添加任何<br/>
或額外的行。另外,數據庫中的行沒有任何空格。
在哪裏可以我出了問題。感謝任何幫助/建議。提前致謝。
動態表輸出
'
對不起,這是一個小錯誤。編輯它。 – SR1092
你有看看你的HTML源代碼嗎?這也是一個「工具」;-) –
回答
的屏幕截圖,我改變了我的SQL查詢和使用COALESCE。代碼如下:
這去除表中的所有空格:
來源
2016-02-25 07:38:34 SR1092
相關問題