Solved

repeating <th> tag to appear every number of lines

Posted on 2011-03-16
9
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link failure 16 70
Session time out quickly. 6 28
Generate PDF's using TCPDF - Initial Set Up 9 33
Looking for suggestions on different user roles best design practices 4 30
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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.

726 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