Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying Records from Access

    I'm currently designing a website in asp classic. One of the pages requires that I pull information from a database. I've accomplished this, but I need to reformate how the results are displayed on the webpage. The code needs to display 7 records in a table, then drop down to a new line and display 7 more or end with the remainder of the records. I hope that makes sence. Right now my code displays the results in one long line that runs off the screen.

    Any help is appreciated! Thank you!

    The code that I am using is below:

    Code:
    <table>
     <tr>
    
    
    <%
    strProvidera="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=<MY DATABASE CONNECTION>\data1.mdb"
    
    
    dim rslog
    set rslog=Server.CreateObject( "ADODB.Recordset" )
    rslog.Open "SELECT * FROM projvid Where referenceid = '1'", strProvidera, , , adCmdTable
    
          if not rslog.eof then 
          do while not rslog.eof
          
     %>
    
    
    
      <td><a href="" onclick="showStuff('<%=rslog("autonum")%>'); return false;"><img src="<%=rslog("thumb")%>" width="50"></a></td>
    
      <% rslog.movenext 
             loop 
             
              else 
            response.write " Nothing matched your search. Please try again." 
             response.write "" 
    
             end if 
             
             %>
             
                     </tr>
             </table>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,695
    Thanks
    80
    Thanked 4,511 Times in 4,475 Posts
    Do you *MEAN* 7 records in a <table>? Or do you really mean 7 records in a <tr> *ROW*??

    You *seem* to mean you want 7 <td>s per <tr> row.

    If so:
    Code:
    <%
    Set conn = Server.CreateObject("ADODB.Connection")
    strProvidera="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=<MY DATABASE CONNECTION>\data1.mdb"
    conn.open strProvidera
    
    ' if referenceid is a number in the table, you should NOT have '...' around the 1 here:
    SQL = "SELECT * FROM projvid Where referenceid = '1'"
    Set rslog = conn.Execute(SQL)
    
    If rslog.EOF Then
        Response.Write "No data to display"
        Response.End
    End If
    %>
    <table>
    <%
    Do Until rslog.EOF
        Response.Write "<tr>" & vbNewLine
        For cell = 1 To 7
            If rslog.EOF Then Exit For
    %>
        <td>
            <a href="" onclick="showStuff('<%=rslog("autonum")%>'); return false;">
                 <img src="<%=rslog("thumb")%>" width="50">
            </a>
        </td>
    <%
            rslog.MoveNext
        Next
        Response.Write "</tr>" & vbNewLine
    Loop
    rslog.Close
    conn.Close
    %>
    </table>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,695
    Thanks
    80
    Thanked 4,511 Times in 4,475 Posts
    As a minor point:

    With all modern browsers, you really do NOT need that dummy <a> in there.

    Just do:
    Code:
        <td>
            <img src="<%=rslog("thumb")%>" 
                 onclick="showStuff('<%=rslog("autonum")%>');"
                 style="width: 50px;" />
        </td>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much! That's exactly what I wanted to do. The code works great!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •