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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

really need to understand this!

Status
Not open for further replies.

ssnapier

Technical User
Feb 17, 2001
67
0
0
US
I am an ASP idiot pretty much, I can read the stuff and make little tweaks here and there, but how can I make buttons appear dynamically? This would be for a car dealer, and the idea would be that they could click on a button (Ford, Chevy, Buick, etc.) and see everything by that maker in the inventory. I only want the buttons to show up if there is one of those brands LISTED in the inventory (an access DB).

The table is called "vehicles" and the column for the makers info is called "manufacturer". I am guessing this would be an IF / ELSE statement, but I have ZERO idea how it would be written. If someone could play tutor here I would really appreciate it!
 
To start off, you need three pages, one to list the brands, one to show cars matching that brand, and one more to show you the details of one particular car. Lets call them brandselect.asp, brand.asp, and car.asp

I am not sure how your database is set up but you will either have a table with brands and ids, with each vehicle referring to a particular brand id, or you will just have a 'brand' column in your vehicles table with the brand name in text.

Lets assume its the second option - the brand name as text in the database.
First you need to select all the DISTINCT brands from the database so you get a list of all brands which are used at least once.

The code for brandselect.asp would be something like this

strSQl = "SELECT DISTINCT brand FROM cars ORDER BY brand"
rs.Open strSQL, objCon, 3
If Not rs.EOF Then
Do Until rs.EOF

%><a href="brand.asp?brand=<%=rs("brand")%>"><%=rs("BRAND")%></a><br/><%

rs.MoveNext
Loop
End If
rs.Close

This should list all of the unique brand names one under each other down the page. When you click on one of the names it will go to another page called brand.asp and also send the name of the brand in the querystring.

In brand.asp, you now just need to select a list of vehicles based on the selected brand e.g.

strSQL = "SELECT * FROM CARS WHERE CAR_BRAND='" & Request.QueryString("brand") & "'"
rs.Open strSQl, objCon, 3
If Not rs.EOF Then
Do Until rs.EOF

%><a href="car.asp?car=<%=rs("carid")%>"><%=rs("carname")%></a><br/><%

rs.MoveNext
Loop
End If
rs.CLose

This will draw a list of all cars matching the selected brand, which when clicked will go to a car.asp page which will show the details of that particular vehicle.

In car.asp you then just need to extract the details for that particular car, using the selected id e.g.

strSQL = "SELECT * FROM cars WHERE carid=" & Request.QueryString("carid")
rs.Open strSQL
If Not rs.EOF Then
%>
Car Name : <%=rs("cartitle")%><br/>
Brand: <%=rs("brand")%><br/>
Price: <%=rs("price")%><br/>

etc.. etc..
<%
ENd IF
rs.CLose

In these examples I have assumed that you already have a connection to your database called objCon, and I have just guessed the names of the fields in your database too - these will obviously need to match the real field names.

Hope this is enough to get you started, let me know if you need further help.

Nick (Webmaster)

info@npfx.com
 
ok, the database name is "lakeside.mdb" and the table name we are looking at it is called "vehicles" and the column in that table is called "manufacturer."

I already have pages in existence from the script I am using (20/20 auto gasllery) and I am creating categories based on these brands so I get that part. I was mainly concerned with how to create the buttons. I will work with what you have provided and report back if I need more assitance!

thanks... [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top