1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

records in table

Discussion in 'C#' started by trixxarn, Sep 6, 2005.

  1. #1
    Hi!

    I have an Access db and I want to display the records in the database in a table. I want to display 5 records on each row, so first it loop through the database and pick the 5 first records and then it creates a new row and pick the next 5 records etc.. So when it have picked out, say 15 records I want it to create a new page and the show the rest of the records on the second page, a paging system.

    I have tested differents methods but without any results.
    SEMrush
    I would be grateful if someone can help me with this.

    // trixxarn :cool:
     
    trixxarn, Sep 6, 2005 IP
    SEMrush
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you need to create an incremental loop that counts up as you step through your recordset - and use an if...then statement to draw your cell/row opening and closing tags every 5 records.

    something like
    <table>
    <%
    i = 0 'your incremental loop - define it outside your recordset loop
    while not recordset.eof 'start your recordset loop
    if i = 0 or i mod 5 = 0 then
    'insert your html to open the row/first cell
    else
    'insert your html to open the 2nd, 3rd, 4th, or 5th cell
    end if
    'display your recordset content
    i = i + 1 'step up your incremental loop by 1.
    if i = 0 or i mod 5 = 0 then
    'insert your html to close the row/last cell
    else
    'insert your html to close the 1st, 2nd, 3rd, or 4th cell
    end if
    recordset.movenext 'proceed to the next record in the recordset.
    wend
    %>
    </table>

    and then create a link to the next page that adds 15 to the query that was passed to the page, i.e. if you pass "15" to the first page, add 15 to that and insert it dynamically as a variable in the hyperlink to the next page, and query the database based on that. Similarly, set your "previous" hyperlink to subtract 15 from that total passed to the page and dynamically add it to that hyperlink as a variable.

    hth

    VG
     
    vectorgraphx, Sep 8, 2005 IP