/ Published in: ASP

A quick and easy function that will output table column names and loop through your SQL recordset results outputting it into a HTML table.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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
URL: http://www.nealgrosskopf.com/tech/thread.asp?pid=40
Comments
