It is not easy to design a SQL query that will repeat headers every 33 rows.
So this should be done in the PHP code.
Why not use a counter, that you increment at every mysql_fetch_array() and
test if !( $counter % 33 )
Side remarks: you could also define a CSS class for TH and use TH as
headers. Thus you avoid having those unpleasant bgcolor='#ff'. Or use
a different TD class for that matter.
Also I suppose that the count( $results ) is intended to be used to define
the width attribute, but it does not seem to appear in your HTML.
HTH
Ignatius
- Original Message -
From: Sam Folk-Williams [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, February 15, 2003 6:26 PM
Subject: [PHP-DB] printing repeat table headers
Hi,
I'm printing the results of a DB query that gets a 300 row staff
directory.
All 300 rows appear on one page. The top of the HTML table has basic
headers
like First Name, Last Name, Email etc, then all 300 rows print
underneath
the headers. What I would like to do is have those headers repeat every 33
rows, so that as the user scrolls down that can still see the table
headers
every so often. I feel like this should be easy, but it's giving me a hard
time. Any suggestions? My code is below.
Thanks, Sam
$tableHeaders =
tr
td class='printRev'bStaff Name/b/td
td class='printRev'bOffice Location/b/td
td class='printRev'bPrimary Telephone/b/td
td class='printRev'bExt/b/td
td class='printRev'bEmail/b/td
td class='printRev'bDirect Telephone/b/td
td class='printRev'bCell/Pager/b/td
/tr
;
echo table width='850' border='1' cellpadding='1' cellspacing='0'
bordercolor='#00';
echo $tableHeaders;
while ($row = mysql_fetch_array($result)) {
$count = count($result);
$staff_id = $row['staff_id'];
$staff_fname = $row['staff_fname'];
$office_name = $row['office_name'];
$staff_lname = $row['staff_lname'];
$staff_phone = $row['staff_phone'];
$staff_phone2 = $row['staff_phone2'];
$staff_email = $row['staff_email'];
$office_phone = $row['office_phone'];
$ext = $row['ext'];
//strip slashes from textfields
$staff_fname = stripslashes($staff_fname);
$staff_lname = stripslashes($staff_lname);
$office_name = stripslashes($office_name);
$tableContent =
tr
td class='print' bgcolor='#ff'$staff_lname, $staff_fname/td
td class='print' bgcolor='#ff'$office_namenbsp;/td
td class='print' bgcolor='#ff'$office_phonenbsp;/td
td class='print' bgcolor='#ff'$extnbsp;/td
td class='print' bgcolor='#ff'$staff_emailnbsp;/td
td class='print' bgcolor='#ff'$staff_phonenbsp;/td
td class='print' bgcolor='#ff'$staff_phone2nbsp;/td
/tr;
echo $tableContent;
} //close while loop
echo
/table
;
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php