Friday, 12 June 2015

CSS to display html table header for each page, also nowrap defining in td

NOTE: Use IE version above 9 to use this, check the print preview before printing. If the content not adjusting set the adjust width property according to page. Set the page set up before.

<style type="text/css">
table,tr,td,th
{
   font-family: arial;vardana;acourier;
   font-size: 8pt;
   border: 1px solid black;
   border-collapse: collapse;
   page-break-inside: auto;
   background: white;
}
th.c1
{
 -moz-transform: rotate(-90deg);
}
thead{
  background: #FFF;
}
@media print
{
  table { page-break-after: always; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  td { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
}
</style>


and while defining table header declare in php as ...

echo "<table border=1 cellspacing=\"0\" cellpading=\"0\" width=\"100%\">";
echo "<thead>";
echo "<tr>";
echo "<th colspan=20><center><font size=4>SPECIAL RECRUITMENT DRIVE FOR FILLING UP OF BACKLOG VACANCIES FOR THE PERSONS WITH DISABILITIES - Sep-2013,  HYDERABAD DISTRICT</font></center>";
echo "<br/>";
if($cat==='4')
echo "<center><font size=3>Merit List For the post of : Sweeper/Scavanger/Thoti/Ayah , Category-$dis-$tgen, &nbsp;&nbsp; Qualification : Read & Write,  No.of Posts: $nop  </b></font></center>";
else if($cat==='-')
echo "<center><font size=2>For the post of <b>Attendar,Sweeper,Lab attendent,MNO,Dhobi,Thoti,Ayah,Scavenger,Watchman and Helper</b></font></center>";
else
echo "<center><font size=3>Merit List For the post of : <b>$pname ,  Category: $dis-$tgen ,  $qualification &nbsp; No. of posts: $nop</b></font></center>";
echo "</th>";
echo "</tr>";
echo "<tr>";
echo  "<th colspan=14><font size=2>Note: MPD-Multiple Disabled, FMD-Family Member(s) Disabled, C/K/W- Cook/Kamati/Sweepper</font></th>";
echo  "<th colspan=5 align=center><font size=3>WAITAGE MARKS</font></th>";
echo "<th></th>";
echo "</tr>";
echo "<tr>";
echo "<th><font size=2><center>Sl. No.</center></font></th>";
echo "<th><font size=2><center>Reg. No.</center></font></th>";
echo "<th><font size=2><center>Post Applied</center></font></th>";
echo "<th><font size=2><center>Name of the Candidate<br>S/o,D/o,H/o</center></font></th>";
echo "<th><font size=2><center>Sex</center></font></th>";
echo "<th><font size=2><center>DOB</center></font></th>";
echo "<th><font size=2><center>Age (in yrs)<br>As On 01-07-2013</center></font></th>";
echo "<th><font size=2><center>Disable Type<br>%</center></font></th>";
echo "<th><font size=2><center>L/NL</center></font></th>";
echo "<th><font size=2><center>MPD<br>(Yes/No)</center></font></th>";
echo "<th><font size=2><center>FMD<br>(Yes/No)</center></font></th>";
echo "<th><font size=2><center>Caste</center></font></th>";
echo "<th><font size=2><center>Acacdemi Qualifn.<br>Marks</center></font></th>";
echo "<th><font size=2><center>Technical Qualifn.</center></font></th>";
echo "<th><font size=2><center>Age</center></font></th>";
echo "<th><font size=2><center>Disa<br>bility</center></font></th>";
echo "<th><font size=2><center>MPD</center></font></th>";
echo "<th><font size=2><center>FMD</center></font></th>";
echo "<th><font size=2><center>Total</center></font></th>";
echo "<th><font size=2><center>Remarks</center></font></th>";
echo "</tr>";
echo "</thead>";

then after the data rows can be defined as

echo "<tr>";
echo "<td align=center><font size=2><b>$sno</b></font></td>";
echo "<td align=center><font size=2><b>$tslo</b></font></td>";
echo "<td nowrap=yes align=center><font size=2><b>$tpostname</b></font></td>";
echo "<td nowrap=yes><font size=2><b>$tname<br>$tfname</b></font></td>";
echo "<td align=center><font size=2><b>$tsex</b></font></td>";
echo "<td nowrap=yes align=center><font size=2><b>$tdob</b></font></td>";
echo "<td nowrap=yes align=center><font size=2><b>$age</b></font></td>";
echo "<td nowrap=yes align=center><font size=2><b>$tdis_type-$tdis_per%</b></font></td>";
echo "<td align=center><font size=2><b>$tlnl</b></font></td>";
echo "<td align=center><font size=2><b>$tmulti_dis</b></font></td>";
echo "<td align=center><font size=2><b>$tofm_dis</b></font></td>";
echo "<td align=center><font size=2><b>$tcaste</b></font></td>";
echo "<td align=center><font size=2><b>$texam_name1<br>$tmarks_exam1/$tmarks_outof1</b></font></td>";
echo "<td align=center><font size=2><b>$texam_name2<br>$texam2</b></font></td>";
echo "<td align=center><font size=2><b>$ma1</b></font></td>";
echo "<td align=center><font size=2><b>$m2</b></font></td>";
echo "<td align=center><font size=2><b>$m3</b></font></td>";
echo "<td align=center><font size=2><b>$m4</b></font></td>";
echo "<td align=center><font size=2><b>$tm_tot</b></font></td>";
echo "<td align=center><b><font size=2>$trem</font></b></td>";
echo "</tr>";