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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying records in multiple vertical html tables... 2

Status
Not open for further replies.

NEL3644

Technical User
Sep 4, 2000
26
US
I want to dispaly a list of records consisting of "start date", "end date", "location", and "state" as column headers...but, the information I want to display is so long. So, as not to loose vertical space, I want to be able to continue displaying the list horizontaly, i. e., have at least 2 tables (each w/ start date, end date, location, and state as headers) that continue displaying records from the same list. Here is my code that doesn't do the task:

p.S. Open for sugestions...

Code:
<TABLE CELLPADDING=&quot;0&quot; BORDER=&quot;1&quot; width=780>

<TR>
<TD>
   <TABLE width=395>
     <TD align=left width=0><B><U>Start Date</U></B></TD>
     <TD align=left width=0><B><U>End Date</U></B></TD>
     <TD align=left width=0><B><U>Location</U></B></TD>
     <TD align=left width=0><B><U>State</U></B></TD>
   </TABLE>
</TD>
<TD>
   <TABLE WIDTH=395>
     <TD align=left width=0><B><U>Start Date</U></B></TD>
     <TD align=left width=0><B><U>End Date</U></B></TD>
     <TD align=left width=0><B><U>Location</U></B></TD>
     <TD align=left width=0><B><U>State</U></B></TD>
   </TABLE>
</TD>
</TR>
					
				
<CFIF GetSessions.RecordCount GTE 1>
   <CFOUTPUT QUERY=&quot;GetSessions&quot;>
     <CFIF (Len(GetSessions.StartDate) is 8) AND (Len    (GetSessions.EndDate) is 8)>
       <TR>
         <TD align=left width=0>#Left(MonthAsString(Mid (StartDate,5,2)),3)# #Mid(StartDate,7,2)#,#Mid(StartDate,1,4)#
         </TD>
	 <TD align=left width=0>#Left(MonthAsString(Mid(EndDate,5,2)),3)# #Mid(EndDate,7,2)#,#Mid
(EndDate,1,4)#
         </TD>
	 <TD align=left width=0>#Location#</TD>
	 <TD align=left width=0>#State#</TD>	
      </TR>
    </CFIF>
  </CFOUTPUT>
</CFIF>
</TABLE>
 
The main reason your code won't work is that you have closed your 2 sub tables before you try to populate them.

Instead of using 2 tables with 4 cols each, you're probably better to use a single table with 8 or 9 cols (an extra col to put some space between is useful). As you go through the query results, you will assign values alternately to the left 4 cols and the right 4 cols.
This will give you results in &quot;across then down&quot; order, ie:

row1 row2
row3 row4
row5 etc...

If you want &quot;down then across&quot; order, like the following, it's a lot harder, because a) you have to know how many rows there are before generating your first table row, so that you can start the second column half way through. This may mean running the query twice. b) You'll also need to store rows 2-122 in memory.

1 123
2 124
3 125
. .
. .
. .
121 243
122

Hope this helps get you started. [sig][/sig]
 
I have a great solution for a two colum table, but it goes down and then over to the next column. Let me know if you'd like to see how I did it.

-NeoTurtle [sig][/sig]
 
If you would show me how you did it that would be great Neo!
Thankx [sig][/sig]
 
NEL . . . Here's my code . . . let me know if you have any questions.


<CFQUERY DATASOURCE=&quot;MyDBase&quot; NAME=&quot;list&quot;>
SELECT Category, CatID
FROM Categories
ORDER BY Category
</CFQUERY>

you can probably combine this next query into the first query, but I'm not quite as SQL-literate as I'd like yet.
<CFQUERY DATASOURCE=&quot;MyDBase&quot; NAME=&quot;count&quot;>
SELECT COUNT(*) AS CatCount
FROM Categories
</CFQUERY>
[/color]
<HTML>

<HEAD>
<LINK REL=&quot;stylesheet&quot; HREF=&quot;MyCSS.css&quot; TYPE=&quot;text/css&quot;>
<TITLE>2 Column Table</TITLE>
</HEAD>

<BODY BGCOLOR=&quot;FFFFFF&quot;>
<TABLE WIDTH=&quot;90%&quot; BORDERCOLOR=&quot;000080&quot; BORDER=&quot;0&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;0&quot; ALIGN=&quot;CENTER&quot; NOWRAP STYLE=&quot;border-left-width: thin; border-right-width: thin; border-top-width: thin; border-bottom-width: thin; border-width: thin; border-color: 000080; border-style: solid;&quot;>
<TR>
<TD BGCOLOR=&quot;000080&quot; COLSPAN=&quot;2&quot; ALIGN=&quot;CENTER&quot;>
<FONT CLASS=&quot;Sub&quot;><B><CFOUTPUT QUERY=&quot;count&quot;>
#CatCount# Categories:

<!--- Count the rows and set a var for it --->
<CFSET CatCol = #CatCount#>
<!--- Divide the rows by 2 and set a var for it --->
<CFSET CatCol2= #CatCol# / 2>
<!--- Round the divided rows in case of an odd number
and add 1 --->
<CFSET CatColT= #Round(CatCol2)# + 1>

</CFOUTPUT></B></FONT>
</TD>
</TR>
<TR>
<TD>
<TABLE BORDER=&quot;1&quot; WIDTH=&quot;100%&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; BORDERCOLOR=&quot;FFFFFF&quot;>
<CFOUTPUT QUERY=&quot;list&quot; MAXROWS=&quot;#Round(CatCol2)#&quot;>
<TR>
<TD WIDTH=&quot;50%&quot; CLASS=&quot;JinMAU&quot;
BGCOLOR=&quot;###IIF(((CurrentRow MOD 2) IS 0),DE('FFFFFF'),de('EEEECC'))#&quot;>
<A HREF=&quot;sites.cfm?CatID=#CatID#&quot; STYLE=&quot;text-decoration: none&quot; TITLE=&quot;#Category#&quot;>
#Category#
</A>
</TD>
</TR>
</CFOUTPUT>
</TABLE>
</TD>
<TD WIDTH=&quot;50%&quot; VALIGN=&quot;TOP&quot;>
<TABLE BORDER=&quot;1&quot; WIDTH=&quot;100%&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; BORDERCOLOR=&quot;FFFFFF&quot;>
<CFOUTPUT QUERY=&quot;list&quot; STARTROW=&quot;#CatColT#&quot;>
<TR>
<TD WIDTH=&quot;50%&quot; CLASS=&quot;JinMAU&quot;
BGCOLOR=&quot;###IIF(((CurrentRow MOD 2) IS 0),DE('EEEECC'),de('FFFFFF'))#&quot;>
<A HREF=&quot;sites.cfm?CatID=#CatID#&quot; STYLE=&quot;text-decoration: none&quot; TITLE=&quot;#Category#&quot;>
#Category#
</A>
</TD>
</TR>
</CFOUTPUT>
</TABLE>
</TD>
</TR>
</TABLE>

<BR>
<!-- Start of Bottom NavBar -->
<CFINCLUDE TEMPLATE=&quot;bottomlink.html&quot;>
<!-- End of Bottom NavBar -->

</BODY>
</HTML>

Let me know if you have any questions. Although I just found a small error in the code where the row color of one side doesn't match the other side. I'm going to be looking at that error soon.

-NeoTurtle [sig][/sig]
 
you could just use #list.RecordCount# to get the number of records, then do the math. No need for a second query ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top