Solved

repeating <th> tag to appear every number of lines

Posted on 2011-03-16
9
232 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

929 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

10 Experts available now in Live!

Get 1:1 Help Now