ofcourse... there should be a "=" after those CachedWIthin's  : p

cachedwithin="#CreateTimeSpan(1,0,0,0)#">
  ----- Original Message -----
  From: Ewok
  To: CF-Talk
  Sent: Wednesday, August 11, 2004 6:40 PM
  Subject: Re: tip of the day

  keep what you got with the 24 hour cache... add your tipUsed column to the table

  when u have a tip to display.. throw an update query in there to flag the tipUsed column as used

  thats pretty much it :)

  so now when the cache expires, the next tip will be grabbed and flagged

  <cfquery name="gettip" datasource="MYDSN" maxrows="1" cachedwithin"#CreateTimeSpan(1,0,0,0)#">
  select * from tbl_tips where tipUsed = 0
  </cfquery>

  this will grab the first tip that it comes to where TipUsed is 0

  now set the tip being used as Used

  <!--- If there was no record returned then the table is either empty or all tips are set to USED and will need to be reset --->
  <cfif GetTip.RecordCount is 0>
      <!--- Reset all tips to NOT USED --->
      <cfquery name="ResetTips" datasource="MYDSN">
      UPDATE tbl_Tips
      SET TipUsed = 0
      </cfquery>

      <!--- after its reset, THEN grab your tip and cache it --->
      <cfquery name="gettip" datasource="MYDSN" maxrows="1" cachedwithin"#CreateTimeSpan(1,0,0,0)#">
      select * from tbl_tips where tipUsed = 0
      </cfquery>

  </cfif>

  <!--- now as long as your table is not empty, you have a tip and can set it to USED (TipUsed = 0) --->
  <cfif GetTip.RecordCount NEQ 0>
      <cfquery name="UpdateTip" datasource="MYDSN">
          UPDATE tbl_Tips
          SET TipUsed = 1
          WHERE TipID = #val(GetTip.TipID)#
      </cfquery>

      <cfoutput>#GetTip.Tip#</cfoutput>
  </cfif>
    ----- Original Message -----
    From: daniel kessler
    To: CF-Talk
    Sent: Wednesday, August 11, 2004 2:02 PM
    Subject: Re: tip of the day

    ok, I have another TOTD question.  I was told that each tip can only be displayed once
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to