Here's my situation I'm tracking hits to my pages and on the front page (of the tracking programme) I have an index page where there is a drop down menu asking the user to select the numebr of past days they wish to search the database. i.e. 1 day, 2days, 3days, 1 week, 1 year. I have a seperate table for these values time_name & time_has_value eg 1 year & 365.
However my query refuses to work when i pick the text strings from the drop down menu eg 1 year, 1 month it just puts 1 in the query therefore 1 day. Here's the code.
<cfparam name="time_name" default="-1">
<cfquery name="time" datasource="#Application.DB#">
Select *
FROM tracking_times
Where time_has_value = <cfqueryparam cfsqltype="cf_sql_varchar" value="#time_name#">
</cfquery>
<cfoutput query="time"> <!---This works fine--->
You chose to select web stats from the past #time.time_name#
</cfoutput>
<!--- Index Page Hits --->
<cfquery name="index_hits" datasource="#Application.DB#">
SELECT page
,COUNT(*) AS indexCount
FROM usertrack
WHERE page="/index.cfm"
AND datetime > curdate() -#time.time_has_value#
GROUP BY page;
</cfquery>
I could just have numbers in the drop down box but i don't want to do it like that.
Any Help much appreciated
However my query refuses to work when i pick the text strings from the drop down menu eg 1 year, 1 month it just puts 1 in the query therefore 1 day. Here's the code.
<cfparam name="time_name" default="-1">
<cfquery name="time" datasource="#Application.DB#">
Select *
FROM tracking_times
Where time_has_value = <cfqueryparam cfsqltype="cf_sql_varchar" value="#time_name#">
</cfquery>
<cfoutput query="time"> <!---This works fine--->
You chose to select web stats from the past #time.time_name#
</cfoutput>
<!--- Index Page Hits --->
<cfquery name="index_hits" datasource="#Application.DB#">
SELECT page
,COUNT(*) AS indexCount
FROM usertrack
WHERE page="/index.cfm"
AND datetime > curdate() -#time.time_has_value#
GROUP BY page;
</cfquery>
I could just have numbers in the drop down box but i don't want to do it like that.
Any Help much appreciated