Grant Holmes Posted January 16, 2008 Share Posted January 16, 2008 Im correctly alternating my row color. Here's my page code that works: <?php include_once("security/SECsecurity.php"); ?> <?php $DOCROOT = $_SERVER['DOCUMENT_ROOT'] ; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>MySite Inactive Requests</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="GOOGLEBOT" CONTENT="NOARCHIVE"> <META NAME="ROBOTS" CONTENT="NONE"> <LINK REL="stylesheet" TYPE="text/css" HREF="martini.css"> <script src="JS/sorttable.js"; ?></script> </HEAD> <BODY> <a name="top"></a> <?php include("dbinfo.inc.php"); mysql_connect(mysql,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM birthdays WHERE Event='request' AND Active='0'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<A name=\"top\"></A><b><center><H1>MySite \"<I>Inactive Requests</I>\":</H1>"; ?> <center><div style='width:100%; background-color:silver; text-align:right'> <?php SECShowAdminLink(); ?> <?php SECShowLogoutLink(); ?> <A href="data.php">Main Data Page</A> </div> <center><div style='width:100%; background-color:#ffe4c4; text-align:center'><BR>This page is showing <I>INACTIVE</I> Requests</B><BR><A href="requests.php">view <I>ALL</I> </A> <A href="requests_active.php">view active only</A></div></center> <table border="1" cellspacing="2" cellpadding="3" class="sortable"> <tr> <TH valign="top">From:</TH> <TH valign="top">City</TH> <TH valign="top">State</TH> <TH valign="top">Zip</TH> <TH valign="top">Country</TH> <TH valign="top">Artist Name</TH> <TH valign="top">Song Title</TH> <TH valign="top">Submitted</TH> <TH valign="top">Status</TH> <TH valign="top"> </TH> </tr> <?php $i=0; while ($i < $num) { $Active=mysql_result($result,$i,"Active"); $firstname=mysql_result($result,$i,"Contact_Info_FirstName"); $lastname=mysql_result($result,$i,"Contact_Info_LastName"); $city=mysql_result($result,$i,"Contact_Info_City"); $state=mysql_result($result,$i,"Contact_Info_State"); $zip=mysql_result($result,$i,"Contact_Info_ZipCode"); $country=mysql_result($result,$i,"Contact_Info_Country"); $email=mysql_result($result,$i,"Contact_Info_Email"); $Bfirstname=mysql_result($result,$i,"Birthday_Info_FirstName"); $Blastname=mysql_result($result,$i,"Birthday_Info_LastName"); $Bcity=mysql_result($result,$i,"Birthday_Info_City"); $Bstate=mysql_result($result,$i,"Birthday_Info_State"); $Bzip=mysql_result($result,$i,"Birthday_Info_ZipCode"); $Bcountry=mysql_result($result,$i,"Birthday_Info_Country"); $Date=mysql_result($result,$i,"DateEntered"); $id=mysql_result($result,$i,"id"); ?> </form> <?php //Alternate Row Color if($i % 2) { echo '<TR bgcolor="silver">'; } else { echo '<TR bgcolor="#ffffff">'; } ?> <td valign="top"><input type="hidden" name="ud_id" value="<? echo $id; ?>"> <STRONG><?php echo "$firstname $lastname"; ?></STRONG><BR><a href="mailto:<?php echo "$email"; ?>"><?php echo "$email"; ?></a></TD> <TD valign="top"><?php echo "$city"; ?></TD> <TD valign="top"><?php echo "$state"; ?></TD> <TD valign="top"><?php echo "$zip"; ?></TD> <TD valign="top"><?php echo "$country"; ?></TD> <TD valign="top"> <?php echo "$Bfirstname"; ?></TD> <TD valign="top"> <?php echo "$Blastname"; ?></TD> <TD valign="top"><?php echo "$Date"; ?></TD> <TD valign="top"> <B>Active?: <?php $checked = $Active ? "checked" : ""; echo "<input type=\"checkbox\" name=\"foo\" $checked>"; ?> </td> <TD valign="top"><CENTER> <a href='requests_edit.php?id=<? echo "$id"; ?>'>edit</a><BR><A href="#top"><IMG src="images/uparrow.gif" border="0" hspace="2" vspace="4" /></A><A href="#bottom"><IMG src="images/downarrow.gif" border="0" hspace="4" vspace="4" /></A></CENTER></TD> </TD> </tr> <?php ++$i; } echo "</table><P><A href=\"#top\">Back to top</A></P></B><BR>"; ?> <BR><BR><BR> <?php include "include/footer.php"; ?> <a name="bottom"></a> </BODY> </html> However, when I use the javascript titles to resort the rows, the color stays with the row. This is not a HUGE deal, but would be nice to fix. Is this a javascript issue? IOW, should I handle this in the javascript? or can we fix it in the PHP? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted January 16, 2008 Share Posted January 16, 2008 I don't know exactly how your js resort works, but why not use a php resort and then you don' t have an issue, the only other way to do the resort. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted January 16, 2008 Author Share Posted January 16, 2008 Why not? Cause I don't know how! THAT is the simple explanation!! Any suggestions or help? The other thing I'd like to do in this page is presort the results that I show to be newest records on the top descending ot the oldest. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted January 16, 2008 Share Posted January 16, 2008 im pretty sure that your JS is rearranging how the rows are ordered (taking one tr and moving it ahead of another etc). And because you define the row color like '<TR bgcolor="#ffffff">' that info is being moved as well. A solution would be to do the row coloring with javascript after the page loads and then recall that function upon a sort, or fix your javascript so that it only moves the data and not the actual rows (tr) Quote Link to comment Share on other sites More sharing options...
drummer101 Posted January 16, 2008 Share Posted January 16, 2008 edit: nvm didn't read entire post Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted January 16, 2008 Author Share Posted January 16, 2008 It's amazing what happens when you read the directions. I've used this javascript for a year or more and forgot the read me file supports some of this. Thanks guys. I already had the "fix" and didn't know it. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted January 16, 2008 Author Share Posted January 16, 2008 BTW, in case anyone wants to look at what I'm using, the script is here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.