Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-01-2012, 12:25 AM   PM User | #1
janthony42
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
janthony42 is an unknown quantity at this point
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>
janthony42 is offline   Reply With Quote
Old 09-01-2012, 01:29 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 09-01-2012, 01:32 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 09-01-2012, 03:26 AM   PM User | #4
janthony42
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
janthony42 is an unknown quantity at this point
Thank you so much! That's exactly what I wanted to do. The code works great!
janthony42 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:07 AM.


Advertisement
Log in to turn off these ads.