Return to Snippet

Revision: 12529
at March 18, 2009 08:11 by neal_grosskopf


Initial Code
function ReturnHTMLTable(query)

	set rs = cn.Execute(query)
	
	rs.MoveFirst 
	response.Write "<table class=""data"" cols=""" & rs.Fields.Count & """>"
	response.Write "<tr>"
	
	For Each oField In rs.Fields
		response.Write "<th>" & oField.Name & "</th>"
	Next
	
	response.Write "</tr>"
	
	Do While Not rs.EOF
	
		response.Write "<tr>"
		
		For Each oField In rs.Fields
		
		response.Write "<td>"
		
		If IsNull(oField) Then 
			response.Write " "
		Else
			response.Write oField.Value
		End If
		
		response.Write "</td>"
		
		Next 
		rs.MoveNext
		
		response.Write "</tr>"
	
	Loop
	
	response.Write "</table>"

end function

Initial URL
http://www.nealgrosskopf.com/tech/thread.asp?pid=40

Initial Description
A quick and easy function that will output table column names and loop through your SQL recordset results outputting it into a HTML table.

Initial Title
Simple Function To Return Recordset Results as Table In HTML

Initial Tags
function, ASP

Initial Language
ASP