We help IT Professionals succeed at work.
Get Started

Print Headers on Every Page

zero118
zero118 asked
on
676 Views
Last Modified: 2008-01-09
Now, by no means is PHP hard for me, but people are asking me to take rows of information along with the headers and make them printable.  By this I mean on each 8.5x11" peice of paper should show the continuing rows of information but also repeat the table headers at the top of every page.  I have no idea how this would work since margins would be different, it would depend on the orientation (portrait or landscape), etc.  Below is my code for the section that displays the information.  Any help or ideas would greatly help.  Thanks.

//DISPLAY LIST OF PARTS FOR A SPECIFIC PUMP -- GET $n (name), $m (mfc info), mc (machine time), $p (price), $pi (price inc), ma (material)
//      $w (weight), $u (used in)
//      NUMBER REQUIRED, NAME, AND PART NUMBER ARE AUTOMATIC
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
      if ($task == 'fulllistshow' && $n != '') {
      
                        $m = $_POST['m'];
                        $w = $_POST['w'];
                        $mc = $_POST['mc'];
                        $pr = $_POST['pr'];
                        $pi = $_POST['pi'];
                        $ma = $_POST['ma'];
                        $u = $_POST['u'];
                        
      
                        $query_mem_1 = "SELECT `name`, `id`, `noreq`, `desc`, `partnum`, ";
                        if ($m == 1){ $query_mem_1 .= "`mfc`, `mfcdesc`, `mfcprtnum`, "; }
                        if ($w == 1){ $query_mem_1 .= "`lbs`, "; }
                        if ($mc == 1){ $query_mem_1 .= "`mchtime`, "; }
                        if ($pr == 1){ $query_mem_1 .= "`lstprc`, "; }
                        if ($pi == 1){ $query_mem_1 .= "`prcinc`, "; }
                        if ($ma == 1){ $query_mem_1 .= "`matcst`, "; }
                        if ($u == 1){ $query_mem_1 .= "`usdin`, "; }
                        $query_mem_1 .= "CAST(SUBSTRING(`partnum`, LOCATE('-', `partnum`) + 1) AS SIGNED) AS `sort_part` FROM `$parts_database_table` WHERE `name`=\"$n\" ORDER BY `sort_part` ASC";
                        mysql_select_db($database_name, $connection);
                        $mem_1 = mysql_query($query_mem_1, $connection) or die(mysql_error());
                        $row_mem_1 = mysql_fetch_assoc($mem_1);
                        $totalRows_mem_1 = mysql_num_rows($mem_1);
                                                      ?>
<head><style>TD.altrow2{background-color: #f7f7f7;}TD.altrow1{background-color: #d9d9d9;}</style></head>
                        <table width="100%" border="0" cellspacing="0" cellpadding="1">
                              <tr>
                                      <td colspan="11" class="prod" style="border-bottom: 2px solid #c0c0c0;"><font face="Tahoma" size="2"><img src="../img/splash-logo.jpg" width="140" height="66" align="bottom" /><strong><font size="3"><?=$n?></font></strong></font><br />
                                    </td>
                              </tr>
                              <tr>
                                  <td width="107" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc; border-left:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Part Number</font></strong>
                                    </td>
                                  <td width="102" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Description<br /></font></strong>
                                    </td>
                                    <td width="72" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">No. Required<br /></font></strong>
                                    </td>
                                    <? if ($m == 1) { ?>
                                    <td width="211" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Manufacturer Information<br /></font></strong>
                                    </td>
                                    <? } ?>
                                    <? if ($pr == 1){ ?>
                                    <td width="97" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">List Price</font></span></strong>
                                    </td>
                                    <? } ?>
                                    <? if ($u == 1) { ?>
                                    <td width="94" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Reference</font></strong>
                                    </td>
                                    <? } ?>
                                    <? if ($w == 1){ ?>
                                    <td width="116" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Weight</font></span></strong>
                                    </td>
                                    <? } ?>    
                                    <? if ($ma == 1){ ?>
                                    <td width="100" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Material Cost </font></strong>
                                    </td>
                                    <? } ?>
                                    <? if ($mc == 1){ ?>
                                    <td width="106" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Machine Time </font></strong>
                                    </td>
                                    <? } ?>
                                    <? if ($pi == 1){ ?>
                                    <td width="106" align="left" valign="top" class="prod" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;"><strong><font face="Tahoma" size="1">Price Increase in % </font></strong>
                                    </td>
                                    <? } ?>
                              </tr>
   
                              <? if ($mem_1){
                              $numOfRows = mysql_num_rows ($mem_1);
                              for ($i = 0; $i < $numOfRows; $i++){
                              $name = mysql_result ($mem_1, $i, "name");
                              $noreq = mysql_result ($mem_1, $i, "noreq");
                              $partnum = mysql_result ($mem_1, $i, "partnum");
                              $desc = mysql_result ($mem_1, $i, "desc");
                              if ($w == 1){$lbs = mysql_result ($mem_1, $i, "lbs");}
                              if ($m == 1){$mfc = mysql_result ($mem_1, $i, "mfc");}
                              if ($m == 1){$mfcprtnum = mysql_result ($mem_1, $i, "mfcprtnum");}
                              if ($m == 1){$mfcdesc = mysql_result ($mem_1, $i, "mfcdesc");}
                              if ($u == 1){$usdin = mysql_result ($mem_1, $i, "usdin");}
                              $id = mysql_result ($mem_1, $i, "id");
                              if ($mc == 1){$mchtime = mysql_result ($mem_1, $i, "mchtime");}
                              if ($ma == 1){$matcst = mysql_result ($mem_1, $i, "matcst");}
                              if ($pi == 1){$prcinc = mysql_result ($mem_1, $i, "prcinc");}
                              if ($pr == 1){$lstprc = mysql_result ($mem_1, $i, "lstprc");}
                              $desc = htmlentities($desc);
                              $mfcdesc = stripslashes($mfcdesc);
                              $alternate = ($i % 2) + 1;   ?>      
                              
                              
                              <tr>
                                  <td width="107" align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-left:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><div align="center"><font face="Tahoma" size="1"><strong><?=$partnum?></strong></font></span></div>
                                    </td>
                                  <td align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$desc?><br /></font>
                                    </td>
                                    <td align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$noreq?><br /></font>
                                    </td>
                                    <? if ($m == 1) { ?>
                                    <td width="211" align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1">name ><?=$mfc?><br />part # ><?=$mfcprtnum?><br />descrip ><?=$mfcdesc?></font></span>
                                    </td>
                                    <? } ?>
                                    <? if ($pr == 1){ ?>
                                    <td width="97" align="right" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1">$<?=$lstprc?></font></span>&nbsp;
                                    </td>
                                    <? } ?>
                                    <? if ($u == 1) { ?>
                                    <td align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$usdin?></font></span>&nbsp;
                                    </td>
                                    <? } ?>
                                    <? if ($w == 1){ ?>
                                    <td width="116" align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$lbs?>lbs</font>&nbsp;</span>
                                    </td>
                                    <? } ?>    
                                    <? if ($ma == 1){ ?>
                                    <td width="100" align="right" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1">$<?=$matcst?></font>
                                    </td>
                                    <? } ?>
                                    <? if ($mc == 1){ ?>
                                    <td width="106" align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$mchtime?></font>
                                    </td>
                                    <? } ?>
                                    <? if ($pi == 1){ ?>
                                    <td width="106" align="left" valign="top" style="border-bottom:1px dotted #cccccc; border-right:1px dotted #cccccc;" class="altrow<?=$alternate?>"><font face="Tahoma" size="1"><?=$prcinc?>&nbsp;</font>
                                    </td>
                                    <? } ?>
                              </tr>
                              <? } ?>
                        </table>
<? }
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE