RE: random by day

2000-10-10 Thread David E. Crawford

This is a multi-part message in MIME format.

--=_NextPart_000_00D4_01C032B7.F448F580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

RE: random by day

Or a bit shorter, taking advantage of the ability to directly access a query
row.

cfquery name="getrecords" datasource="MINE"
SELECT id,author,quote
FROM QUOTES
/cfquery

cfset x=randomize(timeformat(now(),"HHMMSS"))

cfset RandNum = #RandRange(1,getrecords.RecordCount)#

cfoutputRandom Record No = #getRecordsrecord.ID[randnum]#BR
 Quote = #getrecords.Quote[randnum]#BR
 Author = #getrecords.Author[author]# BR


/cfoutput

DC


-Original Message-
From: Larry Juncker [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 20:59
To: CF-Talk
Subject: RE: random by day



  Why not this?

  cfquery name="getrecords" datasource="MINE"
  SELECT *
  FROM QUOTES
  /cfquery

  cfset RandNum = #RandRange(1,getrecords.RecordCount)#

  CFLOOP QUERY="getrecords"
  CFIF CurrentRow EQ #RandNum#
  CFOUTPUT
  Random Record No = #getRecordsrecord.ID#BR
  Quote = #getrecords.Quote#BR
  Author = #getrecords.Author#
  /cfoutput
  /cfif
  /cfloop

  Larry Juncker
  Senior Cold Fusion Programmer
  Heartland Communications Group, Inc.



  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Monday, October 09, 2000 3:50 PM
  To: CF-Talk
  Subject: random by day




  Last week there was a discussion about pulling a random quote from a
  database. I would like to pull a record from a database once a week, lets
  say every sunday. Kind of like the quote of the week.  Whats the best way
to
  do that?

  KM
  ---



  ---
  Get free personalized email at http://www.iname.com
  --
--
  --
  Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
  To Unsubscribe visit
  http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
  send a message to [EMAIL PROTECTED] with 'unsubscribe' in
  the body.



  --

  Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
  To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--=_NextPart_000_00D4_01C032B7.F448F580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
HTMLHEADTITLERE: random by day/TITLE
META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type
META content=3D"MSHTML 5.00.3018.900" name=3DGENERATOR/HEAD
BODY
DIVnbsp;/DIV
DIVnbsp;/DIV
DIVFONT color=3D#ff face=3DArial size=3D2SPAN =
class=3D353394212-10102000Or a=20
bit shorter, taking advantage of the ability to directly access a query=20
row./SPAN/FONTFONT color=3D#ff face=3DArial size=3D2SPAN=20
class=3D353394212-10102000/SPAN/FONT/DIV
DIVFONT color=3D#ff face=3DArial size=3D2SPAN=20
class=3D353394212-10102000/SPAN/FONTnbsp;/DIV
DIVSPAN class=3D353394212-10102000
PFONT color=3D#ff face=3DArial size=3D2lt;cfquery =
name=3D"getrecords"=20
datasource=3D"MINE"gt; BRSELECTnbsp;SPAN=20
class=3D353394212-10102000id,author,quote/SPAN BRFROM QUOTES=20
BRlt;/cfquerygt; /FONT/P
PFONT color=3D#ff face=3DArial size=3D2SPAN=20
class=3D353394212-10102000lt;cfset=20
x=3Drandomize(timeformat(now(),"HHMMSS"))gt;/SPAN/FONT/P
PFONT color=3D#ffFONT face=3DArial size=3D2lt;cfset RandNum =
=3D=20
#RandRange(1,getrecords.RecordCount)#gt; /FONT/FONT/P
PFONT color=3D#ffFONT face=3DArial size=3D2SPAN=20
class=3D353394212-10102000lt;cfoutputgt;/SPAN/FONT/FONTFONT=20
color=3D#ff face=3DArial size=3D2Random Record No =3D =
#getRecordsrecord.IDSPAN=20
class=3D353394212-10102000[randnum]/SPAN#lt;BRgt;nbsp;BR Quote =
=3D=20
#getrecords.QuoteSPAN class=3D353394212-10102000[/SPANSPAN=20
class=3D353394212-10102000randnum]/SPAN#lt;BRgt;nbsp;BR Author =
=3D=20
#getrecords.AuthorSPAN class=3D353394212-10102000[auth/SPANSPAN=20
class=3D353394212-10102000or]/SPAN#nbsp;SPAN=20
class=3D353394212-10102000lt;BRgt;/SPAN/FONT/P
PFONT color=3D#ff face=3DArial size=3D2SPAN=20
class=3D353394212-10102000/SPANBRlt;/cfoutputgt; /FONT/P
PFONT color=3D#ff face=3DArial size=3D2SPAN=20
class=3D353394212-10102000DC/SPAN/FONT/P
PFONT color=3D#ff face=3DArial size=3D2BR/FONT/SPANFONT=20
face=3DTahomaFONT size=3D2-Original Message-BRBFrom:/B =
Larry=20
Juncker [mailto:[EMAIL PROTECTED]]BRBSent:/B Monday, =
October 09,=20

RE: random by day

2000-10-09 Thread Larry Juncker

Why not this?

cfquery name="getrecords" datasource="MINE"
SELECT *
FROM QUOTES
/cfquery

cfset RandNum = #RandRange(1,getrecords.RecordCount)#

CFLOOP QUERY="getrecords"
CFIF CurrentRow EQ #RandNum#
CFOUTPUT
Random Record No = #getRecordsrecord.ID#BR
Quote = #getrecords.Quote#BR
Author = #getrecords.Author#
/cfoutput
/cfif
/cfloop

Larry Juncker
Senior Cold Fusion Programmer
Heartland Communications Group, Inc.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 3:50 PM
To: CF-Talk
Subject: random by day



Last week there was a discussion about pulling a random quote from a
database. I would like to pull a record from a database once a week, lets
say every sunday. Kind of like the quote of the week.  Whats the best way to
do that?

KM
---


---
Get free personalized email at http://www.iname.com

--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: random by day

2000-10-09 Thread Larry Juncker

Why not this?

cfquery name="getrecords" datasource="MINE"
SELECT *
FROM QUOTES
/cfquery

cfset RandNum = #RandRange(1,getrecords.RecordCount)#

CFLOOP QUERY="getrecords"
CFIF CurrentRow EQ #RandNum#
CFOUTPUT
Random Record No = #getRecordsrecord.ID#BR
Quote = #getrecords.Quote#BR
Author = #getrecords.Author#
/cfoutput
/cfif
/cfloop

Larry Juncker
Senior Cold Fusion Programmer
Heartland Communications Group, Inc.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 3:50 PM
To: CF-Talk
Subject: random by day



Last week there was a discussion about pulling a random quote from a
database. I would like to pull a record from a database once a week, lets
say every sunday. Kind of like the quote of the week.  Whats the best way to
do that?

KM
---


---
Get free personalized email at http://www.iname.com

--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



Re: random by day

2000-10-09 Thread pan


From: [EMAIL PROTECTED]




 Last week there was a discussion about pulling a random quote from a database.
I would like to pull a record from a database once a week, lets say every
sunday. Kind of like the quote of the week.  Whats the best way to do that?


The page that displays the quote could have a section of code that looks at
the current day of the week and if it's Sunday - go get a new quote.

cfif ((DayOfweek(Now() IS 1) AND (Hour(Now() IS 0))
 go get a new quote
/cfif

The above will get a new quote during the first hour of Sunday.
However, if the template is not run durng that hour a new quote will
not be retrieved. Likewise, if the template is run n times during that
hour then the quote will be refreshed n times.

It's necessary to
1: ensure the template runs at least once during the first hour of Sunday
2: ensure the timeplate runs only once during that time period.

You could narrow the time frame by checking for minute and seconds,
but the two problems remain.

2: is easy enought to deal with (e.g. query a lastUpdated filed in a db)
lots of ways to do that ..., but 1: remains

A scheduled task would work better - you can set those to run once week
at a specified time. Then, only if the server is down or if you have
a problem with the scheduler will the update fail.
A manual update page will solve that problem as long as you look at
the page that displays the quote on Sunday.

Alternatively, you could write a stored procedure or an embedded
query that checks the age of the last quote pulled from the db.

Alternatively (again), you could work with the lastmodified date of
the displaying page if it is a .html written from a dynamic .cfm.

In short, lots of ways to do this procedure - hope this stimulates
your thinking.

Pan

p.s problem solving skills and critical thinking methods are more
important than a collection of facts and howtos



--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: random by day

2000-10-09 Thread Raymond K. Camden

I believe the best solution is to do the random pick in SQL, but, as a side
note, this code:

 cfset RandNum = #RandRange(1,getrecords.RecordCount)#

 CFLOOP QUERY="getrecords"
   CFIF CurrentRow EQ #RandNum#
   CFOUTPUT
   Random Record No = #getRecordsrecord.ID#BR
   Quote = #getrecords.Quote#BR
   Author = #getrecords.Author#
   /cfoutput
   /cfif
 /cfloop

should be written (or could be :) like so:

cfset RandNum = #RandRange(1,getrecords.RecordCount)#
CFOUTPUTQuote = #GetRecord.Quote[RandNum]#/CFOUTPUT

Even cuter:

CFOUTPUTQuote =
#GetRecord.Quote[RandRange(1,getrecords.RecordCount)]#/CFOUTPUT

Remember that you can treat a query like an array and access a particular
cell and row.

===
Raymond Camden, Cold Fusion Jedi Master for Syntegra (www.syntegra.com)
Allaire Certified Instructor and Member of Team Allaire

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda


 CFLOOP QUERY="getrecords"
   CFIF CurrentRow EQ #RandNum#
   CFOUTPUT
   Random Record No = #getRecordsrecord.ID#BR
   Quote = #getrecords.Quote#BR
   Author = #getrecords.Author#
   /cfoutput
   /cfif
 /cfloop

===
Raymond Camden, Cold Fusion Jedi Master for Syntegra (www.syntegra.com)
Allaire Certified Instructor and Member of Team Allaire

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda


 -Original Message-
 From: Larry Juncker [mailto:[EMAIL PROTECTED]]
 Sent: Monday, October 09, 2000 5:08 PM
 To: CF-Talk
 Subject: RE: random by day


 Why not this?

 cfquery name="getrecords" datasource="MINE"
 SELECT *
 FROM QUOTES
 /cfquery

 cfset RandNum = #RandRange(1,getrecords.RecordCount)#

 CFLOOP QUERY="getrecords"
   CFIF CurrentRow EQ #RandNum#
   CFOUTPUT
   Random Record No = #getRecordsrecord.ID#BR
   Quote = #getrecords.Quote#BR
   Author = #getrecords.Author#
   /cfoutput
   /cfif
 /cfloop

 Larry Juncker
 Senior Cold Fusion Programmer
 Heartland Communications Group, Inc.


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Monday, October 09, 2000 3:50 PM
 To: CF-Talk
 Subject: random by day



 Last week there was a discussion about pulling a random quote from a
 database. I would like to pull a record from a database once a week, lets
 say every sunday. Kind of like the quote of the week.  Whats the
 best way to
 do that?

 KM
 ---


 ---
 Get free personalized email at http://www.iname.com
 --
 --
 --
 Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
 To Unsubscribe visit
 http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
 send a message to [EMAIL PROTECTED] with 'unsubscribe' in
 the body.


 --
 
 Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
 To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.