Solved

repeating <th> tag to appear every number of lines

Posted on 2011-03-16
9
231 Views
Last Modified: 2012-05-11
Hi

How do you repeat the header of a table to appear every say 30 lines of a table?

say for example i have a table with about 7 columns and maybe 200 lines. If I scroll down to halfway down the query i cannot see the header of the table anymore to see which column is which. So to make it easier, is it possible to repeat the header of the table every 30 lines?

Cheers
0
Comment
Question by:Henk_du_Toit
  • 5
  • 4
9 Comments
 
LVL 19

Expert Comment

by:Michael701
Comment Utility
yes, you'll have to post the code that generates the table. here's a start

$header_counter = 0;

while (...)
{
  if (mod($header_counter,30)==0)
   echo "<tr><th>Name</th>.... \n";

  echo "<tr><td>$name.....\n";
  $header_counter++;
}
0
 

Author Comment

by:Henk_du_Toit
Comment Utility
Thank you for your comment... Here is the table code...
<HTML>
    <HEAD>
        <TITLE>Unique Raw Materials Report</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>
		
    </HEAD>
<BODY>
<br>
<CENTER><h2>Unique Raw Materials Report</h2>
<h5>The number of BOMP batches made in the drilldown is for the last 12 months</h5>


<TABLE id="mytable" cellspacing="0">
<tbody>
				<TR>
						<th scope="col">Item</th>
						<th scope="col">Description</th>
						<th scope="col">BOM</th>
						<th scope="col">Description</th>
						<th scope="col">Used in Number of BOM's</th>
						<th scope="col">Batches Made</th>
                </TR>
<br /><b /><hr /><br /><br />

<?PHP
                if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++ )
{
$rm					= $results[OCIColumnName($parsed,1)][$i];
$rmp				= $results[OCIColumnName($parsed,1)][$i-1];
$usedinbom			= $results[OCIColumnName($parsed,5)][$i];
$numbatchprod		= $results[OCIColumnName($parsed,6)][$i];
if ($rm != $rmp) {
?>

</tbody>			
<TR onclick="document.getElementById('cust<?=$i?>').style.display=document.getElementById('cust<?=$i?>').style.display=='none'?'':'none'" title="Click to display the bom's where raw material is being used">
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,1)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,2)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD align = "right"  style="background: #FFEBCD; font-weight: bold;"><?= number_format($usedinbom,0);?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
</tr>
<tbody id="cust<?=$i?>" style="display: none;">

<?}?>
	<tr>      
    <TD></TD>
    <TD></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,3)][$i];?></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,4)][$i];?></TD>
    <TD></TD>
	<td align = "right"><?= number_format($numbatchprod,0);?></td>
	</tr>
<?
}
}
?>
</tbody>
</table>
</BODY>

Open in new window

0
 
LVL 19

Expert Comment

by:Michael701
Comment Utility
try this
<HTML>
    <HEAD>
        <TITLE>Unique Raw Materials Report</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>
		
    </HEAD>
<BODY>
<br>
<CENTER><h2>Unique Raw Materials Report</h2>
<h5>The number of BOMP batches made in the drilldown is for the last 12 months</h5>


<TABLE id="mytable" cellspacing="0">
<tbody>

<?PHP
$header_counter=0;
                if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++ )
{
$rm					= $results[OCIColumnName($parsed,1)][$i];
$rmp				= $results[OCIColumnName($parsed,1)][$i-1];
$usedinbom			= $results[OCIColumnName($parsed,5)][$i];
$numbatchprod		= $results[OCIColumnName($parsed,6)][$i];
if ($rm != $rmp) {

if (($header_counter % 30 ) == 0 )
  {?>
  				<TR>
						<th scope="col">Item</th>
						<th scope="col">Description</th>
						<th scope="col">BOM</th>
						<th scope="col">Description</th>
						<th scope="col">Used in Number of BOM's</th>
						<th scope="col">Batches Made</th>
           </TR>
    <?
  }
$header_counter++;
?>

<TR onclick="document.getElementById('cust<?=$i?>').style.display=document.getElementById('cust<?=$i?>').style.display=='none'?'':'none'" title="Click to display the bom's where raw material is being used">
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,1)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,2)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD align = "right"  style="background: #FFEBCD; font-weight: bold;"><?= number_format($usedinbom,0);?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
</tr>
<tbody id="cust<?=$i?>" style="display: none;">

<?}?>
	<tr>      
    <TD></TD>
    <TD></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,3)][$i];?></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,4)][$i];?></TD>
    <TD></TD>
	<td align = "right"><?= number_format($numbatchprod,0);?></td>
	</tr>
<?
}
}
?>
</tbody>
</table>
</BODY>

Open in new window

0
 

Author Comment

by:Henk_du_Toit
Comment Utility
That did not seem to do the trick... I only displays the first row of the data and when cliking on the first row, it shows the secon and when clicking on the second it shows the third and so on...
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 19

Expert Comment

by:Michael701
Comment Utility
Well that has to do with the javascript and css display:none

On the page. View generated code and post the html here.
0
 

Author Comment

by:Henk_du_Toit
Comment Utility
I have it working now so that it repeats the header every 30 rows but it is hidden...
0
 
LVL 19

Accepted Solution

by:
Michael701 earned 500 total points
Comment Utility
Then I'd double check the pairing of the html tags. Maybe run the generated code through an html validator.

or it could be  that it's getting the hidden tag from a parent object.

If you get stuck, post the generated html code
0
 

Author Comment

by:Henk_du_Toit
Comment Utility
I have run through html validator (CSE) and found no problems... So i played around with where the $header counter sits and got it to work.

Thanks for your help Michael.
<HTML>
    <HEAD>
        <TITLE>Unique Raw Materials Report</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>
		
    </HEAD>
<BODY>
<br>
<CENTER><h2>Unique Raw Materials Report</h2>
<h5>The number of BOMP batches made in the drilldown is for the last 12 months</h5>


<TABLE id="mytable" cellspacing="0">
<tbody>

<?PHP
$header_counter=0;
                if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++ )
{
$rm					= $results[OCIColumnName($parsed,1)][$i];
$rmp				= $results[OCIColumnName($parsed,1)][$i-1];
$usedinbom			= $results[OCIColumnName($parsed,5)][$i];
$numbatchprod		= $results[OCIColumnName($parsed,6)][$i];
if ($rm != $rmp) {

?>
</tbody>
<?
if (($header_counter % 40 ) == 0 )
  {?>
  				<TR>
						<th scope="col">Item</th>
						<th scope="col">Description</th>
						<th scope="col">BOM</th>
						<th scope="col">Description</th>
						<th scope="col">Used in Number of BOMs</th>
						<th scope="col">Batches Made</th>
           </TR>
    <?
  }
$header_counter++;
?>
<TR onclick="document.getElementById('cust<?=$i?>').style.display=document.getElementById('cust<?=$i?>').style.display=='none'?'':'none'" title="Click to display the bom's where raw material is being used">
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,1)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"><?PHP echo $results[OCIColumnName($parsed,2)][$i];?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
    <TD align = "right"  style="background: #FFEBCD; font-weight: bold;"><?= number_format($usedinbom,0);?></TD>
    <TD style="background: #FFEBCD; font-weight: bold;"></TD>
</tr>
<tbody id="cust<?=$i?>" style="display: none;">

<?}?>
	<tr>      
    <TD></TD>
    <TD></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,3)][$i];?></TD>
    <TD><?PHP echo $results[OCIColumnName($parsed,4)][$i];?></TD>
    <TD></TD>
	<td align = "right"><?= number_format($numbatchprod,0);?></td>
	</tr>
<?
}
}
?>
</tbody>
</table>
</CENTER>
</BODY>
</HTML>

Open in new window

0
 

Author Closing Comment

by:Henk_du_Toit
Comment Utility
Thanks for your help
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now