Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
HMOKeefe #1
Populating Dynamic Table
I am putting information about events into an event calendar for any given
date with each date spanning, days, weeks, or months with some dates containing
more than one event. I want to create a dynamic table (3 columns, single row)
on my home page that pulls event data from my database with the three most up
and coming events always populating the table regardless of the span of time
between dates. I am at a loss at how to do this.
HMOKeefe Guest
-
cfloop dynamic variable populating
Hello all, I have what I suspect is a basic question about cfloop. I have a simple database of interest groups + terms of reference (tor) for... -
Populating dynamic checkboxes using query data
I am building an update form for a table that has checkbox data. How can I populate the checkboxes with data from the table so users can see the... -
Dynamic Table ?
Sure it's possible .. there is an Excel driver that works pretty much like the Access driver in the MDAC. That said .. I would personally import it... -
How to create a table with dynamic table name
<html><div style='background-color:'><DIV> <DIV class=Section1> <P class=MsoNormal style="mso-layout-grid-align: none"><FONT face="Times New Roman"... -
Dynamic Table with Dynamic LinkButtons
Looks like I'm not the only one to come across this. Found a post 9 months old that deals with the same thing. Here's the fix: Add line:... -
Dan Bracuk #2
Re: Populating Dynamic Table
Hopefully when you say "dynamic table" you mean html table and not database table.
Once you pull the event data, you can simply display it. There is no need to put it into another table.
Dan Bracuk Guest
-
HMOKeefe #3
Re: Populating Dynamic Table
Yes...this is a dynamic HTML table on my Home Page, but my difficulty is
refreshing the table from the events database so that the three most up and
coming events show up in this three-column table. For instance I have event
data for date1, date2, date3, date4, and date5. I want date1, date2, date3 data
to show up in the HTML table, and when date1 has expired, I want date2, date3,
and date4 data to populate the table and so on...
HMOKeefe Guest
-
Dan Bracuk #4
Re: Populating Dynamic Table
You want to write a query that selects events in the future, sorted by date,
and returns only three records. The specifics depend on your database software
and table structure.
It would be something like,
select top 3 field1, field2, etc
from etc
where event_date > current_date
order by event_date
Dan Bracuk Guest
-
HMOKeefe #5
Re: Populating Dynamic Table
Hmmm...can't seem to make that work. Here my code:
<cfparam name="URL.CurrentDate" default="1">
<cfquery name="eventList" datasource="Functions">
SELECT Title, OneLineDesc, Description, EventDate, EventTime, CategoryID,
EventTimeTo, Name FROM Events5051 WHERE EventDate>'#URL.CurrentDate#' ORDER BY
EventDate ASC
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<table width="800" border="1" cellpadding="2">
<tr>
<td bgcolor="#6666FF"><cfoutput>#eventList.CategoryID# </cfoutput>
<p><cfoutput>#LSDateFormat(eventList.EventDate,'MM MM DD,
YYYY')#</cfoutput><br />
<cfoutput>#eventList.EventTime#</cfoutput>-<cfoutput>#eventList.EventTimeTo#</cf
output></p>
<p><cfoutput>#eventList.OneLineDesc#</cfoutput></p>
<p>"<cfoutput>#eventList.Title#</cfoutput>"</p>
<p>Organized by <cfoutput>#eventList.Name#</cfoutput><br />
</p></td>
<td><p><cfoutput>#eventList.CategoryID#</cfoutput> </p>
<p><cfoutput>#LSDateFormat(eventList.EventDate,'MM MM DD,
YYYY')#</cfoutput><br />
<cfoutput>#eventList.EventTime#</cfoutput>-<cfoutput>#eventList.EventTimeTo#</cf
output></p>
<p><cfoutput>#eventList.OneLineDesc#</cfoutput></p>
<p>"<cfoutput>#eventList.Title#</cfoutput>"</p>
<p>Organized by <cfoutput>#eventList.Name#</cfoutput></p></td>
<td bgcolor="#6666FF"><p><cfoutput>#eventList.Category ID#</cfoutput> </p>
<p><cfoutput>#LSDateFormat(eventList.EventDate,'MM MM DD,
YYYY')#</cfoutput><br />
<cfoutput>#eventList.EventTime#</cfoutput>-<cfoutput>#eventList.EventTimeTo#</cf
output></p>
<p><cfoutput>#eventList.OneLineDesc#</cfoutput></p>
<p>"<cfoutput>#eventList.Title#</cfoutput>"</p>
<p>Organized by <cfoutput>#eventList.Name#</cfoutput></p></td>
</tr>
</table>
</body>
</html>
HMOKeefe Guest
-
mxstu #6
Re: Populating Dynamic Table
HMOKeefe,
Assuming "EventDate" is a date/time column (ie. not a text/varchar type
column)....
1. Since you are simply comparing the "eventDate" against the curent date,
this is not needed.
<cfparam name="URL.CurrentDate" default="1">
2. You query does not limit the number of results returned. Use the sql
operator TOP (or your database's equivalent) with an ORDER BY clause to limit
the number of results to 3 records. Assuming #URL.CurrentDate# is a valid date
in "mm/dd/yyyy" format, try:
---- not tested
SELECT TOP 3 EventDate, ....other columns...
FROM yourTable
WHERE eventDate >= #CreateODBCDate(now())#
ORDER BY EventDate ASC
* Note - This will include any events dated today.
3. Your current output code will display the first record in the query 3
times. Get rid of all those separate cfoutputs tags and use (1) cfoutput tag
with the query attribute to ensure that all three records are displayed.
<table width="800" border="1" cellpadding="2">
<tr>
<cfoutput query="eventList">
<td <cfif currentRow MOD 2 neq 0>bgcolor="##6666FF"</cfif>>
#LSDateFormat(EventDate,'MMMM DD, YYYY')#
... other columns ...
</td>
</cfoutput>
</tr>
</table>
mxstu Guest
-
HMOKeefe #7
Re: Populating Dynamic Table
Great! This works. But could you comment the following code you put in. If I
understood what it was actually doing, I could figure out how to get white text
onto the colored background:
<cfif currentRow MOD 2 neq 0>bgcolor="##6666FF"</cfif>>
In any case thanks for your help!
HMOKeefe Guest
-
mxstu #8
Re: Populating Dynamic Table
> <cfif currentRow MOD 2 neq 0>bgcolor="##6666FF"</cfif>>
Well, I thought in your original code you were alternating the background
color for the different cells. The code above just says if this is an odd
numbered row (1,3, etc), use the background color "6666FF".
mxstu Guest
-
HMOKeefe #9
Re: Populating Dynamic Table
Now I am a bit confused. I only have one row, but three columns. How does
currentRow work if there is only one? Even so I got the right output. Where
would I put the font color information in this statement for the alternating
colored columns
HMOKeefe Guest
-
mxstu #10
Re: Populating Dynamic Table
"CurrentRow" is the query row number. This number is not related to the number
of rows in the html table. In your cfoutput loop, #CurrentRow# reflects the
data row number being output. So in the first loop, #currentRow# is (1), in the
second loop #currentRow# is (2), etc.
CurrentRow | EventDate
-------------------------------------
1 | 10/15/2005
2 | 10/22/2005
3 | 10/28/2005
<table width="800" border="1" cellpadding="2">
<tr>
<cfoutput query="eventList">
<td <cfif currentRow MOD 2 neq 0>bgcolor="##6666FF"</cfif>>
#LSDateFormat(EventDate,'MMMM DD, YYYY')#
... other columns ...
</td>
</cfoutput>
</tr>
</table>
mxstu Guest
-
mxstu #11
Re: Populating Dynamic Table
To answer the second part of that question, although white text isn't always
the best choice from a usuability standpoint, one way would be be to use css
with the MOD check. For example, if you had a class called "whiteText":
<p <cfif currentRow MOD 2 neq 0>class="whiteText"</cfif>> .... query data
values here </p>
mxstu Guest



Reply With Quote

