musicradiolive Posted December 14, 2006 Share Posted December 14, 2006 I've got a content management system setup for my site, but i'm having problems how to work out how to create alternate colours in a table.The page displays a list of pages that exist in the database. But how do i make each one have a different background colour, so it's easier to read?Here is what i am using at the moment to display the pages: <table width="100%" border="2" cellspacing="0" cellpadding="0" id="pagelistings"> <tr> <td><span class="style12">Page Title </span></td> <td><span class="style12">Last Editied On </span></td> <td> </td> </tr> <tr> <td colspan="4"><span class="style6"></span></td> <% strSQL = "Select * FROM tblContent ORDER BY Name" rs.Open strSQL, strCon do while not rs.eof %> </tr> <tr> <td><span class="style6"> <% =removeHTML(rs("Name")) %> </span></td> <td><span class="style6"> <% =rs("LastEdit") %> </span></td> <td><div align="center" class="style6"><a href="page_edit.asp?Title=<% =server.URLEncode(removeHTML(rs("Name"))) %>" class="leftnavbg">Edit </a></div></td> </tr> <% rs.movenext loop %> </table> Any help is appreciated.ThanksJon Link to comment Share on other sites More sharing options...
Mr.Jay Posted December 14, 2006 Share Posted December 14, 2006 <table width="100%" border="2" cellspacing="0" cellpadding="0" id="pagelistings"> <tr> <td><span class="style12">Page Title </span></td> <td><span class="style12">Last Editied On </span></td> <td> </td> </tr> <tr> <td colspan="4"><span class="style6"></span></td> <% count = 0 oncolor = "#FFFFFF" offcolor = "#EDEEED" strSQL = "Select * FROM tblContent ORDER BY Name" rs.Open strSQL, strCon do while not rs.eof if count mod 2 = 0 then bgcolor = oncolor else bgcolor = offcolor end if %> </tr> <tr bgcolor="<%=bgcolor%>"> <td><span class="style6"> <% =removeHTML(rs("Name")) %> </span></td> <td><span class="style6"> <% =rs("LastEdit") %> </span></td> <td><div align="center" class="style6"><a href="page_edit.asp?Title=<% =server.URLEncode(removeHTML(rs("Name"))) %>" class="leftnavbg">Edit </a></div></td> </tr> <% rs.movenext count = count + 1 loop %> </table> try this, just change the offcolor, oncolor variables to match the colours you want. Link to comment Share on other sites More sharing options...
musicradiolive Posted December 14, 2006 Author Share Posted December 14, 2006 Worked a treat, thanks very much.Was very easy to use and provided very fasy, much appreciated.Jon Link to comment Share on other sites More sharing options...
Mr.Jay Posted December 15, 2006 Share Posted December 15, 2006 you are very welcome. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now