Search Results:
<%
YEARQRY = Request.QueryString("year")
BODYQRY = Request.QueryString("bodystyle")
dim RS
Set RS = Server.Createobject ("ADODB.Recordset")
'create SQL query
strSQL = "SELECT * "
strSQL = strSQL & "FROM cars "
strSQL = strSQL & "WHERE "
If Request.QueryString("year") = "%" Then
strSQL = strSQL & "(year LIKE '%')"
ElseIf Not Request.QueryString("year") = "%" Then
strSQL = strSQL & "year = '" & Request.QueryString("year") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("bodystyle") = "%" Then
strSQL = strSQL & "(bodystyle LIKE '%')"
ElseIf Not Request.QueryString("bodystyle") = "%" Then
strSQL = strSQL & "bodystyle = '" & Request.QueryString("bodystyle") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("engine") = "%" Then
strSQL = strSQL & "(engine LIKE '%')"
ElseIf Not Request.QueryString("engine") = "%" Then
strSQL = strSQL & "engine = '" & Request.QueryString("engine") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("epaclass") = "%" Then
strSQL = strSQL & "(epaclass LIKE '%')"
ElseIf Not Request.QueryString("epaclass") = "%" Then
strSQL = strSQL & "epaclass = '" & Request.QueryString("epaclass") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("nationofcorporateorigin") = "%" Then
strSQL = strSQL & "(nationofcorporateorigin LIKE '%')"
ElseIf Not Request.QueryString("nationofcorporateorigin") = "%" Then
strSQL = strSQL & "nationofcorporateorigin = '" & Request.QueryString("nationofcorporateorigin") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("priceblock") = "%" Then
strSQL = strSQL & "(priceblock LIKE '%')"
ElseIf Not Request.QueryString("priceblock") = "%" Then
strSQL = strSQL & "priceblock = '" & Request.QueryString("priceblock") & "' "
Else
End IF
strSQL = strSQL & " AND "
If Request.QueryString("title") = "" Then
strSQL = strSQL & "(title LIKE '%')"
ElseIf Not Request.QueryString("title") = "" Then
strSQL = strSQL & "title = '" & Request.QueryString("title") & "' "
Else
End If
'What to order by?
strSQL = strSQL & " ORDER BY BODYSTYLE, YEAR DESC;"
'Enable Debug by Uncommenting next line.
'----------------------------------------------
response.write "
" & strSQL & ""
' - START OF PAGING -
' Check to see if there is value in the PG querystring. If there
' is, we know that the client is using the Next and/or Prev hyperlinks
' to navigate the recordset.
'------------------------------------
If Request.QueryString("pg") = "" Then
intPage = 1
Else
intPage = Request.QueryString("pg")
End If
'Set parameters for DB connection
'-----------------------------------
Rs.CursorLocation = 3 'adUseClient
Rs.CursorType = 3 'adOpenStatic
' Set the PageSize, CacheSize, and populate the intPageCount and
' intRecordCount variables.
Rs.PageSize = 25
' - END OF PAGING 1 -
'Debug SQL String
'Response.Write strSQL
RS.Open strSQL , Application("DSN")
'- START OF PAGING 2 -
Rs.CacheSize = Rs.PageSize
intPageCount = Rs.PageCount
intRecordCount = Rs.RecordCount
' Now you must double check to make sure that you are not before the start
' or beyond end of the recordset. If you are beyond the end, set
' the current page equal to the last page of the recordset. If you are
' before the start, set the current page equal to the start of the recordset.
If CInt(intPage) > CInt(intPageCount) Then intPage = intPageCount
If CInt(intPage) <= 0 Then intPage = 1
' Make sure that the recordset is not empty. If it is not, then set the
' AbsolutePage property and populate the intStart and the intFinish variables.
If intRecordCount > 0 Then
Rs.AbsolutePage = intPage
intStart = Rs.AbsolutePosition
If CInt(intPage) = CInt(intPageCount) Then
intFinish = intRecordCount
Else
intFinish = intStart + (Rs.PageSize - 1)
End if
End If
'- END OF PAGING 2 -
If RS.Eof And RS.BoF Then
Response.Write "
Sorry no cars found.. You may have invalid search parameters.
Try Again?"
Else
'----------------------------
' Produce the Search Results formatted the way we want.
'----------------------------
VALTOTALWID = 500
VALWIDTH1 = 260
VALWIDTH2 = 80
VALWIDTH3 = 150
Response.write "
" & vbcrlf
Response.Write "" & vbcrlf
Response.Write "| Title | " & vbcrlf
Response.Write "Price Range | " & vbcrlf
Response.Write "Body Style | " & vbcrlf
Response.Write "
" & vbcrlf
'Loop through results til End of file.
Select Case rs("priceblock")
Case "7000099999":
PRIVVAL2 = "$70K-$100K"
Case "5000069999":
PRIVVAL2 = "$50K-$70K"
Case "2000001000000":
PRIVVAL2 = "$200K-$1MIL"
Case "130000199999":
PRIVVAL2 = "$130K-$200K"
Case "150000249999":
PRIVVAL2 = "$150K-$250K"
Case "4000001000000":
PRIVVAL2 = "$400K-$1MIL"
Case "100000149999":
PRIVVAL2 = "$100K-$150K"
Case "3000039999":
PRIVVAL2 = "$30K-$40K"
Case "250000399999":
PRIVVAL2 = "$250K-$400K"
Case "2000029999":
PRIVVAL2 = "$20K-$30K"
Case "4000049999":
PRIVVAL2 = "$40K-$50K"
Case "1500019999":
PRIVVAL2 = "$15K-$20K"
Case "1000014999":
PRIVVAL2 = "$10K-$15K"
Case Else:
PRIVVAL2 = rS("priceblock")
End Select
Select case rs("bodystyle")
'--------------------------
'2-door coupe (2c)
'2-door convertible (2n)
'2-door sedan (2s)
'2-door hardtop (2d)
'2-door targa (2g)
'2-door roadster (2r)
'2-door hatchback/liftback (2h)
'2-door wagon (2w)
'any 2-door car [2c/2n/2s/2d/2g/2r/2h/2w]
'4-door sedan (4s)
'4-door convertible/phaeton (4n)
'4-door hardtop (4d)
'4-door hatchback/liftback (4h)
'4-door wagon (4w)
'any 4-door car [4s/4n/4d/4h/4w]
'minivan [mp]
'van [vn]
'sport-utility 2-door [2u]
'sport-utility 4-door [4u]
'2-door pickup truck [2p]
'4-door pickup truck [4p]
'4-door crossover [4o]
'2-door pickup sedan [2y]
'4-door pickup sedan [4y]
'------------------------------
Case "2c":
BODYST2 = "2-door coupe"
Case "2n":
BODYST2 = "2-door convertible"
Case "2s":
BODYST2 = "2-door sedan"
Case "2d":
BODYST2 = "2-door hardtop"
Case "2g":
BODYST2 = "2-door targa"
Case "2r":
BODYST2 = "2-door roadster"
Case "2h":
BODYST2 = "2-door hatchback/liftback"
Case "2w":
BODYST2 = "2-door wagon"
'-- NEXT GROUP (4 door) --
Case "4s":
BODYST2 = "4-door sedan"
Case "4n":
BODYST2 = "4-door convertible/phaeton"
Case "4d":
BODYST2 = "4-door hardtop"
Case "4h":
BODYST2 = "4-door hatchback/liftback"
Case "4w":
BODYST2 = "4-door wagon"
'-- NEXT GROUP (Other) --
Case "mp":
BODYST2 = "minivan"
Case "vn":
BODYST2 = "van"
Case "2u":
BODYST2 = "sport-utility 2-door"
Case "4u":
BODYST2 = "sport-utility 4-door"
Case "2p":
BODYST2 = "2-door pickup truck"
Case "4p":
BODYST2 = "4-door pickup truck"
Case "4o":
BODYST2 = "4-door crossover"
Case "2y":
BODYST2 = "2-door pickup sedan"
Case "4y":
BODYST2 = "4-door pickup sedan"
Case Else:
BODYST2 = rs("bodystyle")
End Select
For intRecord = 1 to Rs.PageSize
if intRecord mod 2 Then
'BEGIN = ""
Else
'BEGIN = "
"
End if
Response.Write "
" & vbcrlf
Response.Write "| " & rs("title") & " 1 | " & vbcrlf
Response.Write "" & PRIVVAL2 & " | " & vbcrlf
Response.Write "" & BODYST2 & " | " & vbcrlf
Response.Write "
" & vbcrlf
Rs.MoveNext
If Rs.EOF Then Exit for
Next
Response.Write "
" & vbcrlf
'--- PAGING 3 NAV BAR ----
QSVALDN = Instr(Request.QueryString,"&pg")
QSVALDN1 = Instr(Request.QueryString,"&action=results")
WITHOUTACTION = Left(Request.QueryString,QSVALDN1)
WITHOUTPAGEANDACTION = Left(Left(Request.QueryString,QSVALDN1), QSVALDN)
If intPage = 1 Then
TRIMEDQS = Replace(Request.QueryString,"&&", "&")
Else
End If
'TRIMEDQS = WITHOUTACTION
If cInt(intPage) < cInt(intPageCount) Then
TRIMEDQS = Replace(Replace(WITHOUTPAGEANDACTION & "&action=results","&&","&"), "&action=results", "")
End If
If cInt(intPage) = 1 Then
TRIMEDQS = Replace(Request.QueryString, "&action=results", "")
End If
'Response.Write "DN1 = " & QSVALDN1 & "
"
'Response.Write "DN = " & QSVALDN & "
"
'Response.write Request.QueryString & "
"
'Response.write WITHOUTPAGEANDACTION & "
"
' Check to see if the current page is greater than the first page
' in the recordset. If it is, then add a "Previous" link.
If cInt(intPage) > 1 Then
Response.Write "
<< Prev | "
End If
' Check to see if the current page is less than the last page
' in the recordset. If it is, then add a "Next" link.
If cInt(intPage) < cInt(intPageCount) Then
Response.Write "
Next >>"
End If
'--- /END OF NAV PAGING --
rs.Close
Set rs = Nothing
End If
End If %> <%
%>