%
Sub Page_Body() %>
<%
sql = "SELECT * FROM companies WHERE is_bicycle = 0 "
If request("company_name") <> "" Then
sql = sql & " AND name like '%" & replace(request("company_name"),"'","''") & "%' "
End If
If request("business_type") <> "" Then
sql = sql & " AND id IN (SELECT company_id FROM companies_business_types_link WHERE business_type_ID = " & sqlquotes(request("business_type")) & ") "
End If
If request("motorcycle") <> "" Then
sql = sql & " AND id IN (SELECT company_id FROM motorcycles_companies_link WHERE motorcycle_ID = " & sqlquotes(request("motorcycle")) & ") "
End If
If request("motorcycle_product") <> "" Then
sql = sql & " AND id IN (SELECT company_id FROM motorcycle_products_link WHERE motorcycle_product_ID = " & sqlquotes(request("motorcycle_product")) & ") "
End If
If request("region") <> "" Then
sql = sql & " AND province IN (SELECT id FROM provinces WHERE region_ID = " & sqlquotes(request("region")) & ") "
End If
'This is for the Quick Search form....
If request("keyword") <> "" Then
sql = sql & " AND ("
sql = sql & " name like '%" & replace(request("keyword"),"'","''") & "%' "
sql = sql & " OR id IN (SELECT company_id FROM motorcycles_companies_link "&_
" INNER JOIN motorcycles "&_
" ON motorcycles_companies_link.motorcycle_ID = motorcycles.ID "&_
" WHERE motorcycles.name like '%" & replace(request("keyword"),"'","''") & "%') "
sql = sql & " OR id IN (SELECT company_id FROM motorcycle_Products_link "&_
" INNER JOIN motorcycle_products "&_
" ON motorcycle_Products_link.motorcycle_product_ID = motorcycle_products.ID "&_
" WHERE motorcycle_products.name like '%" & replace(request("keyword"),"'","''") & "%') "
sql = sql & " OR province IN (SELECT id FROM provinces WHERE name like '%" & replace(request("keyword"),"'","''") & "%') "
sql = sql & " )"
End If
sql = sql & " ORDER BY name asc"
set rs = server.createobject("adodb.recordset")
rs.open sql, conn, 1, 1
If request("begin") <> "" Then
int_begin = request("begin")
Else
int_begin = 0
End If
int_span = 50
If (int_begin + int_span) > rs.recordcount Then
int_end = rs.recordcount
int_halfway = (cInt((int_end - int_begin)/2)) + int_begin
Else
int_end = int_begin + int_span
int_halfway = cInt(int_begin + int_span/2)
End If
'response.write rs.absoluteposition & "
"
If not rs.eof Then rs.move(int_begin)
%>
|
<%= rs.recordcount %> Results Found.
|
|||||||