Displaying records in a table

D

Darren

Hi Everyone,

This is the problem:

I want to display the some records I have gathered in a recordset
using a SQL query. I want the table to have 3 cells per row (easy so
far). If the recordset happens to contain 15 records, then there are
no problems (3 cells x 5 rows). However, if there are 16 or 17 records
then the final row does not have 3 cells in it anymore (it has 1 or 2
cells respectively). What I would like to do is if there is only 1
cell in the last row then colspan=3 (Haven't decided what to do if
there is 2 cells just yet.)

This is brief example of my code:

<table>
<%
cellcount=0
do while cellcount<4
cellcount=cellcount+1
if cellcount=1 then
response.write("<tr>")
else
end if
response.write("<td>")
response.write(rs("Name"))
response.write("</td>")
if cellcount=3 then
response.write("<tr>")
cellcount=0
else
end if
loop
%>
</table>

I know there is a much simpler solution, I could just create a new
table for every row. But I'm keen to see if there is another way.

Thanks in advance,

Darren Stahlhut
 
G

Gérard Leclercq

After your loop, see how many cells are not written. Write them here with
content &nbsp; and then close the table
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top