Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP recordsets and html tables

Status
Not open for further replies.

sweetleaf

Programmer
Jan 16, 2001
439
CA
Hi,

Is it possible to line up the results of seperate recordsets (in the form of 2 tables side by side) in asp without having to use SHAPE?

I'm basically selecting all dealer numbers into rst1
then i'm selecting all their related stats into rst2(which is an extremely complicated query with various correlated sub queries so need to be implemented as 2 recordsets seperately).

I've gotten as far as displaying all the data by using 2 seperate do while loops, but cannot format the data in asp/html properly - so that it all looks like its in one instead of 2 tables.

NOTE:The data in each will always correlate, so their row counts will always be the same.

Any help is so appreciated,
Mark
 
ok sweet leaf, i have not really used something like this but the below code is d/l from some site (it creates a sortable HTML Table)check whether it helps, or atleast gives u a start....
<%
'***************************************

'Procedure: createSortableList(objConn,
' strSQL, strDefaultSort, intPageSize,
' strLnkedColumnName,strLink,
' strTableAttributes)
'
'Returns: writes a sortable, pagable htm
' l table fill with records from a query
'
'Inputs:
' objConn = a connection object
' strSQL = a string of SQL
' strDefaultSort = a string of the default
' lt sorting column (i.e &quot;FirstName&quot;)
' intPageSize = integer of the number of
' records per page
' strLinkedColumnName = a string of the
' column to place a link on
' strLink = a string of the page link
' strTableAttributes = a string of HTML
' table attributes i.e. &quot;name=myTable bgCo
' lor=steeleblue&quot;
'
'Sample Call:
' createSortableList objConn,strSQL,
' &quot;EmployeeID&quot;,3,&quot;EmployeeID&quot;,&quot;employee_deta
' il.asp&quot;,&quot;border=1 bgcolor='#cccccc'&quot;
'
'Notes:
'
' This is code for a dynamically created
' sortable, pageable HTML table, this
' is a pretty stripped down version. Real
' simple, just call the procedure where you
' want the table, pass it a connection
' object and a SQL string, it will create
' an ADO recordset and fill it into an HTML
' table, it will be fully pageable and
' sortable by clicking the column head. You can a
' also have the values in one column linkab le to
' another page,(example being you have
' an offer number and you click it to go to a
' details page)
' You input the records per page, default sort order,
' and the HTML tables attributes.
' This can be easily made to incorporate
' images for column heads and for navigation
' buttons(maybe i'll post that later if this get a
' good response) Please email me with any questions

'Programmer: Devin Garlit
' (dgarlit@hotmail.com) 4/25/01

Sub createSortableList(objConn,strSQL, strDefaultSort, _
intPageSize, strLinkedColumnName,strLink,strTableAttributes)

Dim RS,strSort, intCurrentPage, strPageName
Dim strTemp, field, strMoveFirst, strMoveNext
Dim strMovePrevious, strMoveLast
Dim i, intTotalPages, intCurrentRecord
Dim intTotalRecords

i = 0

strSort = request(&quot;sort&quot;)
intCurrentPage = request(&quot;page&quot;)
strPageName = Request.serverVariables(&quot;SCRIPT_NAME&quot;)

If strSort = &quot;&quot; then
StrSort = strDefaultSort
End if

if intCurrentPage = &quot;&quot; then
intCurrentPage = 1
end if

set RS = server.CreateObject(&quot;adodb.recordset&quot;)


if strSort <> &quot;&quot; Then strSQL = strSQL & _
&quot; order by &quot; & replace(strSort,&quot;desc&quot;, _
&quot; desc&quot;)


with RS
.CursorLocation=3
.Open strSQL, objConn,3 '3 is adOpenStatic
.PageSize = cint(intPageSize)
intTotalPages = .PageCount
intCurrentRecord = .AbsolutePosition
.AbsolutePage = intCurrentPage
intTotalRecords = .RecordCount
end with

Response.Write &quot;<table &quot; & strTableAttributes & &quot; >&quot; & vbcrlf

'table head
Response.Write &quot;<tr>&quot; & vbcrlf
'loop through the fields in the recordset

for each field in RS.Fields
Response.Write &quot;<td>&quot; & vbcrlf

'check the sort order, if its
'currently ascending, make the link
'descending

if instr(strSort, &quot;desc&quot;) then

Response.Write &quot;<a href=&quot; & strPageName _
& &quot;?sort=&quot;& field.name & _
&quot;&page=&quot; & intCurrentPage & &quot;>&quot; & _
field.name & &quot;</a>&quot; & vbcrlf
else

Response.Write &quot;<a href=&quot; & _
strPageName & &quot;?sort=&quot;& field.name _
&&quot;desc&page=&quot; & intCurrentPage & &quot;>&quot; _
& field.name & &quot;</a>&quot; & vbcrlf
end if

Response.Write &quot;<td>&quot; & vbcrlf
next

Response.Write &quot;<tr>&quot;

'records
for i = intCurrentRecord to RS.PageSize
'display from the current record to the pagesize
if not RS.eof then
Response.Write &quot;<tr>&quot; & vbcrlf
for each field in RS.Fields
Response.Write &quot;<td>&quot; & vbcrlf
if lcase(strLinkedColumnName) _
= lcase(field.name) then
Response.Write &quot;<a href=&quot; & strLink & &quot;?sort=&quot; _
& strSort &&quot;&page=&quot; & intCurrentPage & _
&quot;&&quot; & field.name & &quot;=&quot; & field.value & _
&quot; >&quot; & field.value & &quot;</a>&quot; & vbcrlf
else
Response.Write field.value
end if

Response.Write &quot;<td>&quot; & vbcrlf
next
Response.Write &quot;<tr>&quot; & vbcrlf
RS.MoveNext
end if
next

Response.Write &quot;<table>&quot; & vbcrlf

'page navigation
Select Case cint(intCurrentPage)
case cint(intTotalPages) 'if its the last page give only links to movefirst and move previous
strMoveFirst = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort &&quot;&page=1 >&quot;& &quot;First&quot; &&quot;</a>&quot;
strMoveNext = &quot;&quot;
strMovePrevious = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort & &quot;&page=&quot; & _
intCurrentPage - 1 & &quot; >&quot;& &quot;Prev&quot; &&quot;</a>&quot;
strMoveLast = &quot;&quot;
case 1 'if first page only move next and move last
strMoveFirst = &quot;&quot;
strMoveNext = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort &&quot;&page=&quot; & _
intCurrentPage + 1 & &quot; >&quot;& &quot;Next&quot; &&quot;</a>&quot;
strMovePrevious = &quot;&quot;
strMoveLast = &quot;<a href=&quot; & strPageName _
& &quot;sort=&quot;& strSort &&quot;&page=&quot; & _
intTotalPages & &quot; >&quot;& &quot;Last&quot; &&quot;</a>&quot;
case else
strMoveFirst = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort & &quot;&page=1 >First&quot; &&quot;</a>&quot;
strMoveNext = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort & &quot;&page=&quot; & _
intCurrentPage + 1 & &quot; >&quot;& &quot;Next&quot; &&quot;</a>&quot;
strMovePrevious = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort & &quot;&page=&quot; & _
intCurrentPage - 1 & &quot; >&quot;& &quot;Prev&quot; &&quot;</a>&quot;
strMoveLast = &quot;<a href=&quot; & strPageName & _
&quot;?sort=&quot;& strSort &&quot;&page=&quot; & _
intTotalPages & &quot; >&quot;& &quot;Last&quot; &&quot;</a>&quot;
end select

With Response
.Write strMoveFirst & &quot; &quot;
.Write strMovePrevious
.Write &quot; &quot; & intCurrentPage & &quot; of &quot; & intTotalPages & &quot; &quot;
.Write strMoveNext & &quot; &quot;
.Write strMoveLast
end with

if RS.State = &H00000001 then 'its open
RS.Close
end if
set RS = nothing
end sub
%>

Regards
Niraj [noevil]
 
Try nesting the tables. Have one main table and each row will represent a dealer. Each row will have two cells - the first being the dealer name. The second cell can then be another table which contains all the dealer stats. Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top