RE: Daily Tip help...
Thanks Tony, I have it working good now... here is The Tip Of The Day code incase anyone is wants to do the same. I set up the scheduler to run this once a day. I may set it every hour. -Code-- !--- reset all tips to inactive --- cfquery name=clear_active datasource=myDSN UPDATE Tips SET active = 0 /cfquery !--- Lets Count the Records --- cfquery name=CountRecords datasource=myDSN SELECT COUNT(Tips.Tip_ID) AS maxrecords FROM Tips /cfquery !--- Set the random record --- cfset RandomCount = randRange(1, #CountRecords.maxrecords#) !--- Now set the new tip as active --- cfquery name=set_new datasource=myDSN UPDATE Tips SET active = 1 WHERE tip_id = #RandomCount# /cfquery --END- Then all I do is output the active tip. Thanks for the help Neal Bailey Internet Marketing Manager E-mail:mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] _ From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 8:52 PM To: CF-Talk Subject: RE: Daily Tip help... or, actually... cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = #randRange(1-100) --if you have 100, or whatever your total is /cfquery since you probably will not have a 0 :) also, your integer mismatch was most likely on the new() creating a uuid there, and not an INT which that column seems to be. tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
I have several of these things,displaying random tips or random quotes. They all work flawlessly in SQLServerwith a query like: Select top 1 Tipid, Tip, Source, SourceEMail from Tips Order By NEWID() Each time the query is run, it produces a query containing a single record taken at random from the table.If you wanted to run it only once per day, you could put it in a scheduled task, and put the result into an application variable, or perhaps have a CACHEWITHIN parameter set in the CFQUERY tag. Cheers Mike Kear Windsor, NSW, Australia AFP Webworks http://afpwebworks.com _ From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Tuesday, 18 May 2004 12:52 PM To: CF-Talk Subject: RE: Daily Tip help... or, actually... cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = #randRange(1-100) --if you have 100, or whatever your total is /cfquery since you probably will not have a 0 :) also, your integer mismatch was most likely on the new() creating a uuid there, and not an INT which that column seems to be. tony [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
why not put them in a database, with asort order, and whatever day of the month it is, show that based on the sort order numbered from 1-28 or something like that? or just do it randomly.where each page refresh would show a new one? tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 9:51 PM To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
Since there are only 40, it's no big deal to get the whole lot from the database and get CF to choose. Int(now()) converts today into an integer. You can use mod to turn that daily number into a recurring cycle.. cfquery name=tips SELECT. /cfquery cfset tipNum = (int(now()) mod tips.recordCount) + 1 cfoutput#tips.tip[tipNum]#/cfoutput Regards, Matthew Walker _ From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Tuesday, 18 May 2004 1:51 p.m. To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
How about flag the tip record with a bit field called 'live'. Then you can see the tip that's live, and then take the next tip in whatever order you have them. Greg -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:11 PM To: CF-Talk Subject: RE: Daily Tip help... why not put them in a database, with asort order, and whatever day of the month it is, show that based on the sort order numbered from 1-28 or something like that? or just do it randomly.where each page refresh would show a new one? tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 9:51 PM To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
Well this is kind of what I am trying to do... I want to automate it though so that all I have to do is keep adding tips and the system will just continue to rotate through them either randomly or in order either is ok with me. Over time I will be adding more tips so this database could have hundreds as time goes on. The code below is what I am trying to do but I keep getting an Integer mismatch error. All I want is a simple Tip of the day thing just like Ben Forta has on his site or Like Sitepoint. Thanks for the help... !--- Sets Scheduler in cfadmin to run this once a day --- !--- reset all tips to inactive --- cfquery name=clear_active datasource=myDSN UPDATE tips SET active_tip = 0 /cfquery cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = newID() /cfquery - !--- Dipslay Tip on page --- cfquery name=get_tip datasource=myDSN SELECT daily_tip FROM tips WHERE active_tip = 1 /cfquery Neal Bailey Internet Marketing Manager E-mail:mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] _ From: Greg Luce [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 8:18 PM To: CF-Talk Subject: RE: Daily Tip help... How about flag the tip record with a bit field called 'live'. Then you can see the tip that's live, and then take the next tip in whatever order you have them. Greg -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:11 PM To: CF-Talk Subject: RE: Daily Tip help... why not put them in a database, with asort order, and whatever day of the month it is, show that based on the sort order numbered from 1-28 or something like that? or just do it randomly.where each page refresh would show a new one? tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 9:51 PM To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = newID() /cfquery that's going to create a uuid in sql server I would do this cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = #randRange(0-100) --if you have 100, or whatever your total is /cfquery some cf anals will set that random number before the query...but either way will work. tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:41 PM To: CF-Talk Subject: RE: Daily Tip help... Well this is kind of what I am trying to do... I want to automate it though so that all I have to do is keep adding tips and the system will just continue to rotate through them either randomly or in order either is ok with me. Over time I will be adding more tips so this database could have hundreds as time goes on. The code below is what I am trying to do but I keep getting an Integer mismatch error. All I want is a simple Tip of the day thing just like Ben Forta has on his site or Like Sitepoint. Thanks for the help... !--- Sets Scheduler in cfadmin to run this once a day --- !--- reset all tips to inactive --- cfquery name=clear_active datasource=myDSN UPDATE tips SET active_tip = 0 /cfquery cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = newID() /cfquery - !--- Dipslay Tip on page --- cfquery name=get_tip datasource=myDSN SELECT daily_tip FROM tips WHERE active_tip = 1 /cfquery Neal Bailey Internet Marketing Manager E-mail:mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] _ From: Greg Luce [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 8:18 PM To: CF-Talk Subject: RE: Daily Tip help... How about flag the tip record with a bit field called 'live'. Then you can see the tip that's live, and then take the next tip in whatever order you have them. Greg -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:11 PM To: CF-Talk Subject: RE: Daily Tip help... why not put them in a database, with asort order, and whatever day of the month it is, show that based on the sort order numbered from 1-28 or something like that? or just do it randomly.where each page refresh would show a new one? tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 9:51 PM To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Daily Tip help...
or, actually... cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = #randRange(1-100) --if you have 100, or whatever your total is /cfquery since you probably will not have a 0 :) also, your integer mismatch was most likely on the new() creating a uuid there, and not an INT which that column seems to be. tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:47 PM To: CF-Talk Subject: RE: Daily Tip help... cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = newID() /cfquery that's going to create a uuid in sql server I would do this cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = #randRange(0-100) --if you have 100, or whatever your total is /cfquery some cf anals will set that random number before the query...but either way will work. tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:41 PM To: CF-Talk Subject: RE: Daily Tip help... Well this is kind of what I am trying to do... I want to automate it though so that all I have to do is keep adding tips and the system will just continue to rotate through them either randomly or in order either is ok with me. Over time I will be adding more tips so this database could have hundreds as time goes on. The code below is what I am trying to do but I keep getting an Integer mismatch error. All I want is a simple Tip of the day thing just like Ben Forta has on his site or Like Sitepoint. Thanks for the help... !--- Sets Scheduler in cfadmin to run this once a day --- !--- reset all tips to inactive --- cfquery name=clear_active datasource=myDSN UPDATE tips SET active_tip = 0 /cfquery cfquery name=set_new datasource=myDSN UPDATE tips SET active_tip = 1 WHERE tip_id = newID() /cfquery - !--- Dipslay Tip on page --- cfquery name=get_tip datasource=myDSN SELECT daily_tip FROM tips WHERE active_tip = 1 /cfquery Neal Bailey Internet Marketing Manager E-mail:mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] _ From: Greg Luce [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 8:18 PM To: CF-Talk Subject: RE: Daily Tip help... How about flag the tip record with a bit field called 'live'. Then you can see the tip that's live, and then take the next tip in whatever order you have them. Greg -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:11 PM To: CF-Talk Subject: RE: Daily Tip help... why not put them in a database, with asort order, and whatever day of the month it is, show that based on the sort order numbered from 1-28 or something like that? or just do it randomly.where each page refresh would show a new one? tony Tony Weeg sr. web applications architect navtrak, inc. [EMAIL PROTECTED] 410.548.2337 www.navtrak.net -Original Message- From: Bailey, Neal [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 9:51 PM To: CF-Talk Subject: Daily Tip help... Hello All... I am having an issue with trying to build a rotating daily tips script. All I want to do is have a database full of tips and everyday have a new tip display on the front page. I thought it was easy but for some reason I cannot get it to work. I have about 40 tips so all it needs to do is select the next record everyday. Can someone point me in the right direction... I have looked all over the net for examples but oddly enough there are not any that do such a simple thing, at least that I could find. Thanks for any help on this I'm sure its simple, but for some reason I cant figure it out. - Neal _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]