?
Solved

repeating <th> tag to appear every number of lines

Posted on 2011-03-16
9
Medium Priority
?
237 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
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses

752 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