2013-10-16 52 views
0

我使用PHP顯示MySQL中的大型數據集。如果用戶試圖打印它,它有大約50頁的數據。在HTML中重複表格標題

整個數據是使用顯示錶中的字段中的數據表和簡單的PHP echo-s顯示。

我需要的是 - 當用戶試圖給它或導出打印到PDF的Safari(蘋果機),表頭應該出現在所有頁面。如何才能做到這一點?

謝謝

編輯:我附上了表頭,但它不起作用。這是一個簡單的HTML頁面,沒有任何腳本顯示數據庫中的數據。

代碼

echo "<table border='1'> 
<thead> 
<tr> 
<th></th> 
<th></th> 
<th></th> 
<th></th> 
<th colspan=13>Item Info</th> 
<th colspan=4>Lot Info</th> 
</tr> 
<tr> 
<th bgcolor='#C8E3FF'>S.No.</th> 
<th bgcolor='#C8E3FF'>Party Name</th> 
<th bgcolor='#C8E3FF'>Item No.</th> 
<th bgcolor='#C8E3FF'>Date</th> 

<th>Flower</th> 

<th bgcolor='#C8E3FF'>Lot No.</th> 
<th bgcolor='#C8E3FF'>Avg Wt.</th> 
<th bgcolor='#C8E3FF'>Total Weight</th> 
<th bgcolor='#C8E3FF'>Detail Page</th> 
</tr></thead><tfoot></tfoot><tbody>"; 

    echo "<tr>"; 
    echo "<td bgcolor='#C8E3FF' rowspan=".$itemCounter.">".$sno."</td>"; 
    echo "<td bgcolor='#C8E3FF' rowspan=".$itemCounter.">".$row['partyName']."</td>"; 

    while($row2 = mysqli_fetch_array($itemquery)) 
    { 
     $itemNo++; 
     echo "<td bgcolor='#C8E3FF'>".$itemNo."</td>"; 
     echo "<td bgcolor='#C8E3FF'>".$row2['date']."</td>"; 


      //$flower = $flower + $row2['flower']; 
      echo "<td>".$row2['flower']."</td>"; 



     echo "<td bgcolor='#C8E3FF'>".$row2['lotno']."</td>"; 
     echo "<td bgcolor='#C8E3FF'>".$row2['avgwt']."</td>"; 
     if ($row2['totalWeight'] == 0) 
     { 
      echo "<td bgcolor='#C8E3FF'> </td>"; 
     } 
     else{ 
      $totalWt = $totalWt + $row2['totalWeight']; 
      echo "<td bgcolor='#C8E3FF'>".$row2['totalWeight']."</td>";  
     } 

     echo "<td bgcolor='#C8E3FF'>".$row2['detailPage']."</td>"; 
     echo "</tr>"; 
    } 
    echo "<td bgcolor='#C8E3FF'><b>Total</b></td>"; 


    echo "<td><b>".$flower."</b></td>"; 



     echo "<td bgcolor='#C8E3FF'></td>"; 
     echo "<td bgcolor='#C8E3FF'></td>"; 

      echo "<td bgcolor='#C8E3FF'><b>".$totalWt."</b></td>"; 

     echo "<td bgcolor='#C8E3FF'></td>"; 
     echo "</tr>"; 
     echo "<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>"; 

} 
echo "</tbody></table>"; 

回答

2

據我知道,如果你正確使用THEAD部分的表中,該標題將在每個頁面上重複。

http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3

http://www.w3schools.com/tags/tag_thead.asp加入:

定義和用法

該標記用於在HTML表組頭的內容。

該元件與和元件一起使用,以指定一個表(標題,正文,頁腳)的每個部分。

瀏覽器可以使用這些元素來啓用獨立於頁眉和頁腳的滾動表格主體。另外,當打印跨越多個頁面的大型表格時,這些元素可以使表格頁眉和頁腳打印在每頁的頂部和底部。

的標籤必須在下列範圍內使用:作爲元素的子元素,之後的任何和元件,以及任何前,和元素。

+0

我將編輯我的問題以反映代碼。 –