Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

An SQL query query

Enthusiast ,
Nov 13, 2007 Nov 13, 2007
Hi, I am using ASP, VB and MSAccess.

I am trying to pass a parameter from one page to another to drill down. Basically, I have one product entry that is in multiple categories on my website. So, say it's a dress, it is therefore related to category 1 which is 'Girls', but it is also more specifically related to category 2 which is 'Girls Dresses'.

The way I have set this up is to have a column called MultiCategoryID that holds both the number 1 and 2 like this: /1/2/

When a user clicks a link to look at dresses, the parameter 2 is passed, but my query on the result page is wrong in some way because no records are displaying even though there is content to display. This is what I have so far:

SELECT *
FROM Products
WHERE MultiCategoryID LIKE '/catdrill/'
ORDER BY ProductID DESC

The parameter settings are:
Name: catdrill
Type: Numeric
Value: Request("MCID") MCID is the url parameter being passed
Default value: 2

Only when I test the Default value with an exact match of /1/2/ does any product display. What have I done wrong here? Is there a way to get it to recognise that I want it to pick specific numbers between the slashes rather than the whole lot?

Thanks.

Mat
TOPICS
Server side applications
228
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 13, 2007 Nov 13, 2007
LATEST
Try changing the way you pass the parameters, slashes are not good seperators. Use periods to seperate the categories. you could use the split function and use each array value to search your db. Here is some code that will insert multiple values into a db.

<%
calltime = (request.form("ct[]"))
servname = (request.form("sn[]"))
inputtime = (request.form("now_time[]"))
laptopid = (request.form("laptop[]"))

calltime_array = SPLIT(calltime,",")
srvrname_array = SPLIT(servname,",")
inputtime_array = SPLIT(inputtime,",")
laptopid_array = SPLIT(laptopid,",")

For i = LBound(srvrname_array) TO UBound(srvrname_array)

Dim objRS, objComm
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = MM_lplconnect_STRING
objComm.CommandText = "INSERT INTO call_logs(serverID, call_times, log_time, laptopIP) Values ('" & srvrname_array(i) & "', '" & calltime_array(i) & "', '" & inputtime_array(i) & "', '" & laptopid_array(i) & "')"
objComm.Execute
Next
%>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines