Jump to content

Alternate Table Colours


musicradiolive

Recommended Posts

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

<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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...