Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Help needed with creating a query...

Posted 28 Feb 2002 10:08:03
1
has voted
28 Feb 2002 10:08:03 Q Qwerty posted:
I'm a complete novice to ASP/VB handcoding so maybe can help me out with the next question. I have a database with certain categories. When a certain product belongs to a categorie I use an Access Yes/No checkbox. For the real good understanding, when it's checked I want it to be displayed on the page holding the specific categorie. I need to know how to select it through my navigation links. E.g. when I click the navigation link for "Categorie X" I need all the products belonging to that categorie to be listed on the new page. I think I have to use a certain variable but I haven't got the slightest idea to do this.

Thanks again everyone!

Replies

Replied 01 Mar 2002 22:48:04
01 Mar 2002 22:48:04 andrew de guia replied:
Hi Reinvs,

You have to pass it as a query string appended to your navigation link.

Ex.
<a href=categoryi.html?category=I>Category I </a>

you can access the paremeter passes by this link by:
Request.querystring("category"

Hope this helps.

Regards,

Andrew
Macromedia Technical Support

Andrew de Guia
Macromedia Technical Support
Replied 02 Mar 2002 02:38:36
02 Mar 2002 02:38:36 Andrew Watson replied:
Aright Reinvs,

The simplest way to do this is to change your database to make your database relational.
You should have a table called Products and a table called Categories. Each should have a unique identifier key (an autonumber field in Access)called ProductID and CategoryID respectively. The products table should also contain a Number field called CategoryID and this should be 'joined' to the unique key field (CategoryID) in the Categories table using the relationships tool in Access. Now all your records (products) in the Products table have a number that ties them to a category.

Now create an ASP page. Create a simple SELECT ALL Recorsdet from the Categories table and drag a field (probably something like CategoryName), into the right column of a two column (1 row) table.

Select this entire table row and apply the repeat region behaviour to show all records.
This will give you a page showing, simply all the categories in a list.

Create another ASPpage and do EXACTLY the same as above only this time the recordset should be a SELECT ALL from the Products Table WHERE the CategoryID field is equal to request.querystring("CategoryID"
(this is done quickest using the simple recordset databindings tool in UD)

Now go back to the first ASP page (the one with the categories on it) and select the field you dragged into the right table cell, Add a hyperlink to this. In the hyperlink dialogue box select the second ASP page (the one with the filtered products recordset) and then click the Parameters button. In the parameters dialogue box write CategoryID in the first row of the Name column, then click the wee lightning icon on the right of the right hand column. This will pop up a recordset dialogue box showing the Categories recordset. select the CategoryID field and hit OK.

Thats it, view the categories page and click on a category and youll go to the products page showing only the desired products.


Sorry if this is patronising.

<img src=../images/dmxzone/forum/icon_smile_approve.gif border=0 align=middle>

Check out the beginner tutorials at udnewbie.com

Cheers

Leed

Reply to this topic