[thelist] RePost - One for the GURU's asp loop

Brian Cummiskey Brian at hondaswap.com
Mon May 2 09:23:20 CDT 2005


Brian Delaney wrote:

>> I need to write the records 3 companies per row:
>>
>> company1 company2 company3
>> addr addr addr
>> addr1 addr1 addr1
>> city,state zip city,state zip city,state zip

in your select statement, only select the fields--  company, addr, 
addr1, city, state, zip.

<%

' Build the table -->	
	if not rst.EOF then
%>

	<table>
		<tr>
<%

	' set up the 3 headers...
		for x = 0 to rst.Fields.count - 1
			Response.Write "<th>" & trim(rst.Fields(x).Name) & "</th>" & vbcrlf				
		next

		for x = 0 to rst.Fields.count - 1
			Response.Write "<th>" & trim(rst.Fields(x).Name) & "</th>" & vbcrlf				
		next

		for x = 0 to rst.Fields.count - 1
			Response.Write "<th>" & trim(rst.Fields(x).Name) & "</th>" & vbcrlf				
		next

		' end the header row...

		response.write "</tr>"
		
		
		do until rst.eof
			
			response.write "<tr>"

		
			' now do this 3 times as well...
						
			for x = 0 to rst.Fields.count - 1
				Response.Write "<td>" & trim(rst.Fields(x).Value) & "</td>" & vbcrlf				
			next
			
			rst.MoveNext
			
			for x = 0 to rst.Fields.count - 1
				Response.Write "<td>" & trim(rst.Fields(x).Value) & "</td>" & vbcrlf				
			next
			
			rst.MoveNext

			for x = 0 to rst.Fields.count - 1
				Response.Write "<td>" & trim(rst.Fields(x).Value) & "</td>" & vbcrlf				
			next

			Response.Write "</tr>" & vbcrlf	
			rst.MoveNext
		loop	
%>
	</table>

%>


if you want a border or something in between, you can always add another 
<td></td> cell in between the columns of the header and the data set.

HTH



More information about the thelist mailing list