Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a drop down menu value and searching for it in the database

Status
Not open for further replies.

maverik59

Programmer
Oct 30, 2002
67
GB
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=&quot;time_name&quot; default=&quot;-1&quot;>
<cfquery name=&quot;time&quot; datasource=&quot;#Application.DB#&quot;>
Select *
FROM tracking_times
Where time_has_value = <cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#time_name#&quot;>
</cfquery>

<cfoutput query=&quot;time&quot;> <!---This works fine--->
You chose to select web stats from the past #time.time_name#
</cfoutput>


<!--- Index Page Hits --->
<cfquery name=&quot;index_hits&quot; datasource=&quot;#Application.DB#&quot;>
SELECT page
,COUNT(*) AS indexCount
FROM usertrack
WHERE page=&quot;/index.cfm&quot;
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
 
what is in you select box?
what are you putting in the value area of the select box.?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top