<%@ Language=VBScript %> Walsh Atkinson Metal Machinery <% Dim oConn Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "Provider=MSDASQL;Driver={SQL Server};Server=sql2.hostdepot.com;Database=plasma;UID=plasma;PWD=bjr-walsh;" Dim sql Dim s Dim rs ' check for a bot... Dim uAgent uAgent = UCase(Request.ServerVariables("HTTP_USER_AGENT")) Dim bot bot = (InStr(1, uAgent, "GOOGLEBOT") > 0) ' Google bot = (bot Or InStr(1, uAgent, "MSNBOT") > 0) ' MSN bot = (bot Or InStr(1, uAgent, "YAHOO! SLURP") > 0) ' Yahoo bot = (bot Or InStr(1, uAgent, "ASK JEEVES") > 0) ' Ask Jeeves If Not bot Then Dim m m = Request.QueryString("m") If m = "" Then m = 0 Else m = CInt(m) End If Dim t t = Request.QueryString("t") If t = "" Then t = 0 Else t = CInt(t) End If Dim c c = Request.QueryString("c") If c = "" Then c = 0 Else c = CInt(c) End If Dim p p = Request.QueryString("p") If p = "" Then p = 0 Else p = CInt(p) End If %>


<% If p <> 0 Then Set rs = oConn.Execute("SELECT URL FROM PM_Machines WHERE ID = " & p) %>
" <% If UCase(Left(rs("URL"), 5)) = "HTTP:" Then %> target=_blank <% End If %>> <% Else %> <% End If %>

Category:

<% ' sql = "SELECT * FROM PM_Categories ORDER BY PM_Categories.Name" sql = "SELECT DISTINCT PM_Categories.* " & _ "FROM PM_Products, PM_Machines, PM_Manufacturers, PM_ProductTypes, PM_Categories " & _ "WHERE (PM_Products.Manufacturer = PM_Manufacturers.ID) " & _ "AND (PM_Products.Type = PM_ProductTypes.ID) " & _ "AND (PM_Products.Category = PM_Categories.ID) " & _ "AND (PM_Products.Machine = PM_Machines.ID)" If m <> 0 Then sql = sql & " AND (PM_Products.Manufacturer = " & m & ")" If t <> 0 Then sql = sql & " AND (PM_Products.Type = " & t & ")" sql = sql & " ORDER BY PM_Categories.Name" Set rs = oConn.Execute(sql) %>

Manufacturer:

<% ' sql = "SELECT * FROM PM_Manufacturers ORDER BY PM_Manufacturers.Name" sql = "SELECT DISTINCT PM_Manufacturers.* " & _ "FROM PM_Products, PM_Machines, PM_Manufacturers, PM_ProductTypes, PM_Categories " & _ "WHERE (PM_Products.Manufacturer = PM_Manufacturers.ID) " & _ "AND (PM_Products.Type = PM_ProductTypes.ID) " & _ "AND (PM_Products.Category = PM_Categories.ID) " & _ "AND (PM_Products.Machine = PM_Machines.ID)" If t <> 0 Then sql = sql & " AND (PM_Products.Type = " & t & ")" If c <> 0 Then sql = sql & " AND (PM_Products.Category = " & c & ")" sql = sql & " ORDER BY PM_Manufacturers.Name" Set rs = oConn.Execute(sql) %>

Product Type:

<% ' sql = "SELECT * FROM PM_ProductTypes ORDER BY PM_ProductTypes.Name" sql = "SELECT DISTINCT PM_ProductTypes.* " & _ "FROM PM_Products, PM_Machines, PM_Manufacturers, PM_ProductTypes, PM_Categories " & _ "WHERE (PM_Products.Manufacturer = PM_Manufacturers.ID) " & _ "AND (PM_Products.Type = PM_ProductTypes.ID) " & _ "AND (PM_Products.Category = PM_Categories.ID) " & _ "AND (PM_Products.Machine = PM_Machines.ID)" If m <> 0 Then sql = sql & " AND (PM_Products.Manufacturer = " & m & ")" If c <> 0 Then sql = sql & " AND (PM_Products.Category = " & c & ")" sql = sql & " ORDER BY PM_ProductTypes.Name" Set rs = oConn.Execute(sql) %>

Product Model:

<% Dim w w = 250 sql = "SELECT DISTINCT PM_Machines.Model, PM_Machines.ID, " & _ "PM_Manufacturers.Name AS MName, PM_ProductTypes.Name AS TName, PM_Categories.Name AS CName " & _ "FROM PM_Products, PM_Machines, PM_Manufacturers, PM_ProductTypes, PM_Categories " & _ "WHERE (PM_Products.Manufacturer = PM_Manufacturers.ID) " & _ "AND (PM_Products.Type = PM_ProductTypes.ID) " & _ "AND (PM_Products.Category = PM_Categories.ID) " & _ "AND (PM_Products.Machine = PM_Machines.ID)" If m <> 0 Then sql = sql & " AND (PM_Products.Manufacturer = " & m & ")" Else w = w + 125 End If If t <> 0 Then sql = sql & " AND (PM_Products.Type = " & t & ")" End If If c <> 0 Then sql = sql & " AND (PM_Products.Category = " & c & ")" End If If t = 0 Or c = 0 Then w = w + 225 End If sql = sql & " ORDER BY PM_Manufacturers.Name, PM_Categories.Name, PM_ProductTypes.Name, PM_Machines.Model" Set rs = oConn.Execute(sql) If Not rs.Eof Then %> <% End If %>

  disabled="true" <% End If %>>
<% Else ' a bot is indexing this page (give them a huge list of links to our product pages)... Set rs = oConn.Execute("SELECT DISTINCT PM_Machines.URL, PM_Machines.Model, " & _ "PM_Manufacturers.Name AS MName, PM_ProductTypes.Name AS TName, PM_Categories.Name AS CName " & _ "FROM PM_Machines, PM_Categories, PM_Products, PM_Manufacturers, PM_ProductTypes " & _ "WHERE (PM_Products.Manufacturer = PM_Manufacturers.ID) " & _ "AND (PM_Products.Type = PM_ProductTypes.ID) " & _ "AND (PM_Products.Category = PM_Categories.ID) " & _ "AND (PM_Products.Machine = PM_Machines.ID) " & _ "ORDER BY PM_Categories.Name, PM_Manufacturers.Name, PM_ProductTypes.Name, PM_Machines.Model") Do Until rs.Eof s = rs("CName") & "/" & rs("MName") & ": " & rs("Model") & " (" & rs("TName") & ")" %> "><%=s%>
<% rs.MoveNext Loop End If %>