New Problem. A have advertisements but want to assign them to different pages.
I guess im just new to it all and lack the thinking.
Im trying to set it all up to where you can put it in three locations if you
want. Im using ORs but the ORs stop the query once it finds something. So if I
Ok I think I fixed it.
I forgot to ORDER BY newID()
Thank you.
New Problem. A have advertisements but want to assign them to
different pages. I guess im just new to it all and lack the thinking.
Im trying to set it all up to where you can put it in three locations
if you want. Im
It was pulling in the wrong ADID when showing an image... I had to put
#GetAds.ADID# in the Where instead of just #ADID#.
!--- incrementvalue Adds one to an integer, so it adds one to views---
CFSET add = incrementvalue(val(GetADs.views))
CFQUERY datasource=Brooke name=AddView
UPDATE
Ah yes that will be because there is another variable somewhere in the
request with the name ADID and it was using that instead of the one
coming from your query.
Thats why you should always scope your variables, unless there is a
specific reason not to. If you scope them, the function
I tried Mikes code:
CFQUERY DATASOURCE=#Green# NAME=GetADs
SELECT top 1 *
FROM dbo.banner_left
ORDER BY newID()
/CFQUERY
works great for the random but it screws up the views.
CFSET add = incrementvalue(val(GetADs.views))
CFQUERY datasource=Brooke name=AddView
UPDATE dbo.banner_left
SET
Tried Isaac's and it doesnt count any of the views.
CFQUERY DATASOURCE=#Green# NAME=getCachedAds
cachedwithin=#CreateTimeSpan(1,0,0,0)#
SELECT *
from dbo.banner_left
/CFQUERY
!--- RandRange is Random integer between first number and second(1st,2nd) ---
CFSET ADID =
I would have thought the counting of views wouldnt have anything to do
with how the banner is selected. They are two different db
transactions.
Are you sure that .val(GetADs.views) is giving you a numeric value?
Are you sure that incrementvalue(val(GetADs.views)) is giving you a
value 1 greater
Yea you're right Ike. Story of my life - I relax for once and make
a smart-alec comment and it whips around and bites me.
But in my own defence, mine takes less typing! LOL .
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
Yea you're right Ike. Story of my life - I relax for once and make
a smart-alec comment and it whips around and bites me.
Yer lucky you added the my dad can beat up your dad comment at the end,
otherwise I might not have picked up on the fact that you were jokin'
around. :)
But in my own
I am using a varent from sparty2809 on http://tutorial323.easycfm.com/ It works
great but was created for ACCESS and uses an autonumber datatype. Its great
when you just keep adding advertisments but when you delete one there is now a
gap in the +one ADID (int - identity specification). When
I am using a varent from sparty2809 on http://tutorial323.easycfm.com/
It works great but was created for ACCESS and uses an autonumber
datatype. Its great when you just keep adding advertisments but when
you delete one there is now a gap in the +one ADID (int - identity
specification).
Why not select out of the database using a random selection of the
indexes that are there? Then you never have to worry about gaps.
They dont matter.
CFQUERY DATASOURCE=#Green# NAME=GetADs maxrows=1
SELECT top 1 *
FROM dbo.banner_left
ORDER BY newID()
/CFQUERY
That will select a random
I am using a varent from sparty2809 on http://tutorial323.easycfm.com/
It works great but was created for ACCESS and uses an autonumber
datatype. Its great when you just keep adding advertisments but when
you delete one there is now a gap in the +one ADID (int - identity
Here's my suggested modification
!--- Gets Maximum number of ads---
CFQUERY DATASOURCE=#Green# NAME=getCachedAds
cachedwithin=#CreateTimeSpan(1,0,0,0)#
SELECT * dbo.banner_left
/CFQUERY
!--- RandRange is Random integer between first number and second(1st,2nd) ---
CFSET ADID =
slight correction - i had a redundancy - you dont need maxrows=1 as
well as SELECT top 1 so the query would be better written as
CFQUERY DATASOURCE=#Green# NAME=GetADs
SELECT top 1 *
FROM dbo.banner_left
! if you want to add some restrictions like for example only
select from the ones
Ike, your query will still attempt to select records that have been
deleted The original problem was that the keys werent sequential
if some records have been deleted. That's going to happen as ads are
removed. Using the technique I use, it selects a random record
from the records that
Mike Kear said:
Ike, your query will still attempt to select records that have been
deleted The original problem was that the keys werent sequential
if some records have been deleted. That's going to happen as ads are
removed. Using the technique I use, it selects a random record
17 matches
Mail list logo