Solved

repeating <th> tag to appear every number of lines

Posted on 2011-03-16
9
233 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
ID: 35153484
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
ID: 35160935
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
ID: 35161865
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:Henk_du_Toit
ID: 35162107
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
 
LVL 19

Expert Comment

by:Michael701
ID: 35162539
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
ID: 35177057
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
ID: 35177384
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
ID: 35184800
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
ID: 35184806
Thanks for your help
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

809 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