Click to See Complete Forum and Search --> : Business Directory using ASP


dthatsme
07-13-2007, 01:40 PM
I'm creating a business directory for my site. I'm creating an ASP page for each category - Automotive, Business, etc. I have all of the individual business information in one database.
I'm having an issue trying to figure out to display the listings of each individual category. In my access database I have a field called "category" but I only want the listings for Automotive display on the auto.asp page, for example.
I'm trying to figure out the Query I'd need. I'm thinking it's somthing like this: SELECT *
FROM database
WHERE Cat1 = Automotive
ORDER BY Company ASC

Can anyone help me out?

nbcrockett
07-14-2007, 05:26 PM
Your select statement would look like this.
"SELECT * FROM database WHERE Cat1 = 'Automotive' ORDER BY Company ASC"
You know to save you some work you could create one page that is dynamic based off of a variable. Obviously I don't know everything else that's on your page, but just an idea. All your links to the page would look like this.
www.domain.com/page.asp?Cat1=Automotive
and your select statement would look like this
"SELECT * FROM database WHERE Cat1 = '" & Request.QueryString("Cat1") & "' ORDER BY Company ASC"

buntine
07-15-2007, 01:09 AM
Its generally best to follow referential standards and use numeric primary keys instead of text-based identifiers.

Cheers.

dthatsme
07-16-2007, 12:54 PM
Your select statement would look like this.
"SELECT * FROM database WHERE Cat1 = 'Automotive' ORDER BY Company ASC"
You know to save you some work you could create one page that is dynamic based off of a variable. Obviously I don't know everything else that's on your page, but just an idea. All your links to the page would look like this.
www.domain.com/page.asp?Cat1=Automotive
and your select statement would look like this
"SELECT * FROM database WHERE Cat1 = '" & Request.QueryString("Cat1") & "' ORDER BY Company ASC"

The only thing that will be on the page is the specific listing. Like for Auto only the Auto listings will be there. Will I still need to do the dynamic page then?

I did get it working with the code that you gave me and it looks great! Thanks!

dthatsme
07-16-2007, 12:55 PM
Its generally best to follow referential standards and use numeric primary keys instead of text-based identifiers.

Cheers.

I have the primary key set as an autonumber.

nbcrockett
07-16-2007, 01:10 PM
You don't need to do the dynamic page. It was just an idea to help you save time. You would write just one page instead of a page for all of the different catagories.

dthatsme
07-16-2007, 01:10 PM
Here's another question -- how do I get info from two columns to show. I've got cat1, cat2, cat3 columns. Auto could be in col2 or col3 and I want them to show. I tried this:

SELECT *
FROM database
WHERE Cat1 OR Cat2 = 'Automotive'
ORDER BY Company ASC

I tested and all of the listings showed up. What am I missing?

Thanks!
Dawn

nbcrockett
07-16-2007, 01:17 PM
Try this.

"SELECT * FROM database WHERE Cat1 = 'Automotive' OR Cat2 = 'Automotive' ORDER BY Company ASC"

dthatsme
07-16-2007, 01:35 PM
That worked. Of course it was the only option I didn't try. :rolleyes:

Thanks!!

nbcrockett
07-16-2007, 01:42 PM
Of course! Trust me know. It's always either the one thing you didn't try or the last thing you try.