Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Question on loops
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

The Omega
New Member

55 Posts

Posted - 26 September 2003 :  14:54:05  Show Profile
Is there any way to have a table and display 5 records(dates) on a row then start a new row with 5 more records on a line.

I have a loop currently and the only way i have now is individual rows or columns that scroll across....

Doug G
Support Moderator

USA
6493 Posts

Posted - 26 September 2003 :  15:08:54  Show Profile
Just add a secondary counter, something like

Dim i, nHoriz
nHoriz = 5
i = 0

rs.movefirst
Do while not rs.eof
  if i mod nHoriz = 0 then
    response.write "<tr>"
  end if
  response.write "<td>" & rs("datefield") & "</td>"
  if i mod nHoriz = 0 and i > 0 then
    response.write "</tr>"
  end if
  i = i + 1
  rs.movenext
loop

Standard Disclaimer: untested code

This snip will output <tr> tags only when nHoriz number of <td> has been output

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page

The Omega
New Member

55 Posts

Posted - 26 September 2003 :  15:32:41  Show Profile

Response.Write "<table border=""1"" bordercolor=""C2C281"" width=""100%"" cellpadding=""0"" cellspacing=""0"">"
DispatchesDate = Request.QueryString("DispatchesDate")

	set my_Conn = Server.CreateObject("ADODB.Connection")
  my_Conn.Open strConnString
	strSql = "SELECT DISTINCT ad_DispatchDate FROM dispatches"
	set rsDispatches = my_Conn.Execute (strSql)
	
		if rsDispatches.EOF then
  		recDispatchesCount = ""
  	else
  		allDispatchesData = rsDispatches.GetRows() 'adGetRowsRest
  		recDispatchesCount = UBound(allDispatchesData,2)
  	end if
  
  	rsDispatches.close
  	set rsDispatches = nothing
  
  	if recDispatchesCount = "" then
  		strerror = "No Dispatches Found"
			response.write strerror
  	else
		dDate = 0
			  
 				 
			for iDispatches = 0 to recDispatchesCount
			DispatchesDate = allDispatchesData(dDate, iDispatches)

  
						Response.Write "<tr align=""center"">" & vbNewLine & _
									   "<td width=""10%""><A HREF=""dispatch2.asp?Action=PastDate&DispatchDate=" & DispatchesDate & """>" & DispatchesDate & "</td>" & vbNewLine & _
									   "<td width=""90%""></td>" & vbNewLine & _
									   "</tr>" & vbNewLine
									   									
  		next
		Response.Write "</table>"
  	end if

		
	set rsDispatches = nothing
	my_Conn.Close
	set my_Conn = nothing


this is my current code using an array...
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07