Solved

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

Posted on 2003-11-25
4
152 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
ID: 9822702
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
ID: 9823802
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
ID: 9823834
yeah that would work 2.. :-)

0
 
LVL 11

Expert Comment

by:hart
ID: 9823838
but then u will have 2 queries instead of just 1

Regards
Hart
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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