Displaying records in a table

Discussion in 'ASP General' started by Darren, Mar 11, 2005.

  1. Darren

    Darren Guest

    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
     
    Darren, Mar 11, 2005
    #1
    1. Advertising

  2. After your loop, see how many cells are not written. Write them here with
    content &nbsp; and then close the table
     
    Gérard Leclercq, Mar 11, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lisa Calla

    displaying records with many fields

    Lisa Calla, Oct 8, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    460
    Lisa Calla
    Oct 10, 2005
  2. Luke Airig
    Replies:
    0
    Views:
    800
    Luke Airig
    Dec 31, 2003
  3. technoplonker

    Displaying 5 random records from a database table

    technoplonker, Feb 9, 2004, in forum: ASP General
    Replies:
    1
    Views:
    121
    Manohar Kamath [MVP]
    Feb 9, 2004
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    468
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    670
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page