looping question

J

Jeff

ok.. here is my script

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("/singlestour/fpdb/singles_tour.mdb")

SET oRS= Server.CreateObject("ADODB.Recordset")

strSQL = "Select username, total_score from current order by total_score
desc"

SET oRS= Conn.Execute(strSQL)

Const MAX_COLS = 2
Dim iCol, username, total_score

Response.Write "<table border='1'>"
Do While not oRS.Eof
iCol = 0
Response.Write "<tr>"
Do While iCol < MAX_COLS
If oRS.Eof Then
username = "&nbsp;"
total_score = "&nbsp;"
Else
username = oRS("username").value
total_score = oRS("total_score").value
oRS.moveNext
End If

Response.Write "<td>" & username & "</td>"
Response.Write "<td>" & total_score & "</td>"
Response.Write "<td>""against""</td>"
iCol = iCol + 1
Loop
Response.Write "</tr>"
Loop
Response.Write "</table>"
%>

and the display looks like this
http://www.gig-golf.com/singlestour/scores.asp but i want it to look like
this http://www.gig-golf.com/singlestour/scoresexample.asp

i am trying how to learn how to put html into asp.. but the main thing i
want to get rid of, is having the extra column on the right that says
against... i just want it in the middle.... any ideas??
Thanks
Jeff
 
J

J. Alan Rueckgauer

If iCol = 0 Then
Response.Write "<td>""against""</td>"
End If

Take the quotes off ""against"":
Response.Write "<td>against</td>"

Also, you could change your outer Do to "Do Until oRS.EOF". This is more
efficient as it's not having to perform negation on the condition.

Alan
 
J

Jeff

Ok. I got that part. But what about only having "against" in between the
first set of records, and not the second. like i have in the second example?
jeff
 
J

J. Alan Rueckgauer

Did you try what I suggested?

By wrapping "<td>against</td>" in the "If iCol = 0" test, that means it will
only be written when iCol = 0. Presumably iCol is your counter to determine
if you're ready to start a new row, and if iCol = 0 then you've just output
the "left" columns..

If you haven't also realized, you should have an ElseIf iCol = 1 clause to
just write "<td>&nbsp;<td>" if you've just output the "against" details and
before starting a new row. This keeps the HTML consistent.
 
J

Jeff

sorry.. i did see that... and forgot to put that in there.. thanks a bunch
bud :)
Jeff
 

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

Similar Threads

classi asp 0
Java script on classic ASP page 6
Combo box on ASP page 2
show value in text box 2
ASP/Java 3
display value in textbox 1
Object required error 0
ASP code not working Vbscript Return function 3

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top