Solved

only list certain fields in output query until those fields are selected, then auto show next fields

Posted on 2003-11-25
4
148 Views
Last Modified: 2013-12-24
this is a doozy -

my db table lists timeslots:

eg
02/04/2004 08:30:00
02/04/2004 9:00:00
02/04/2004 9:30:00
02/04/2004 14:00:00
02/04/2004 14:30:00
02/04/2004 15:00:00

02/05/2004 08:30:00
02/05/2004 9:00:00
02/05/2004 9:30:00
02/05/2004 14:00:00
02/05/2004 14:30:00
02/05/2004 15:00:00

etc

my client wants the webpage to show only the 1st am and pm slots until they're "taken" then wants to auto show the next in line so:

1st:
02/04/2004 08:30:00, 02/04/2004 14:00:00
02/05/2004 08:30:00, 02/05/2004 14:00:00

then when these are deleted (they get deleted from the table when they are "taken)

show the next 2:

02/04/2004 09:00:00, 02/04/2004 14:30:00
02/05/2004 09:00:00, 02/05/2004 14:30:00

here's my existing code:

<cfquery name="rsTimes" datasource=#MM_connCalArts_DSN# username=#MM_connCalArts_USERNAME# password=#MM_connCalArts_PASSWORD#>
SELECT count(*) as slotsremain,  timeslots_theater.timeslots, mix_theater.cities_id, cities_theater.cities,
mix_theater.timeslots_id, mix_theater.mix_id, timeslots_theater.id FROM timeslots_theater,
mix_theater, cities_theater WHERE timeslots_theater.id = mix_theater.timeslots_id
AND cities_theater.id = mix_theater.cities_id AND cities_id = '#rsTimes__MMColParam#'
group by timeslots
order by timeslots asc
</cfquery>

__________________________________________________

<cfoutput query="rsTimes" group="timeslots">
    <li><A HREF="application.cfm?#Trim(MM_keepURL & Iif(MM_keepURL NEQ '',DE('&'),DE('')) & 'mix_id=' & rsTimes.mix_id)#" class="craig">#dateformat(rsTimes.timeslots, 'mmmm d, yyyy')#&nbsp; #timeformat(rsTimes.timeslots, 'h:MM tt')#</A>
  </cfoutput>

0
Comment
Question by:phillystyle123
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
hart earned 150 total points
Comment Utility
ok is ur data always going to be in pairs

that is total being 6 or 8 or 10 etc..

then ty this out

take this in a variable
<cfset Lst_Date = "02/04/2004 08:30:00~02/04/2004 9:00:00~02/04/2004 9:30:00~02/04/2004 14:00:00~02/04/2004 14:30:00~02/04/2004 15:00:00">

<cfloop from="1" to="#ListLen(Lst_Date,'~')#" Index="Date_Index">
    <cfif Date_Index EQ 1>
      #ListGetAt(Lst_Date,Date_Index,'~')#<br>
      #ListGetAt(Lst_Date,Evaluate(ListLen(Lst_Date,'~')/2),'~')#
    <cfelse>
      #ListGetAt(Lst_Date,Date_Index,'~')#<br>
      #ListGetAt(Lst_Date,Evaluate((ListLen(Lst_Date,'~')/2)+(Date_Index-1)),'~')#
    </cfif>
</cfloop>

i haven't tested it..
but the logic is that i am getting the first element and then dividing the length of the list by 2 which will gie the 4 th one
let me know


Regards
Hart
0
 

Author Comment

by:phillystyle123
Comment Utility
i'll try this out hart- but it occured to me, couldn't i just use a query for AM and one for PM and then just do something like

<cfoutput query="AM" maxrows ="1">.................

<cfoutput query="PM" maxrows ="1">.................
0
 
LVL 11

Expert Comment

by:hart
Comment Utility
yeah that would work 2.. :-)

0
 
LVL 11

Expert Comment

by:hart
Comment Utility
but then u will have 2 queries instead of just 1

Regards
Hart
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now