本文介紹了使用 PHP 打印水平而不是垂直的表格的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
問題:
我有一個垂直打印的表格,但我希望它改為水平打印.誰能就如何實現這一目標提供指導?
I have a table that prints out vertical but I would like it to print horizontal instead. Anyone who can give guidance on how this can be achieved?
PHP 代碼:
echo '
<table class="table table-condensed table-bordered neutralize">
<tbody>
<tr>
<td><b>Kriterium</td>
<td><b>Betyg</td>
</tr>
';
while ($row = mysql_fetch_assoc($result))
{
echo '
<tr>
<td>'.$i.'</td>
<td>'.$row['RID'].'</td>
</tr>
';
$i++;
}
echo '
</tbody>
</table>
';
當前輸出:
期望的輸出:
推薦答案
循環查詢結果,首先構建您想要的兩行,然后將它們添加到您的表中:
Loop through your query results first building up the two rows that you want and then add them into your table afterwards:
$kriterium = '';
$betyg = '';
while ($row = mysql_fetch_assoc($result))
{
$kriterium .= '<td>'.$i.'</td>';
$betyg .= '<td>'.$row['RID'].'</td>';
$i++;
}
echo '
<table class="table table-condensed table-bordered neutralize">
<tbody>
<tr>
<td><b>Kriterium</td>'.$kriterium .'
</tr>
<tr>
<td><b>Betyg</td>'.$betyg .'
</tr>
</tbody>
</table>
';
這篇關于使用 PHP 打印水平而不是垂直的表格的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!