Jump to content

Help with sub categories desperately needed!


Arizona
 Share

Recommended Posts

Hi,I'm new to all this and really need help on something that I've been banging my head against for a while.Basically I have a shopping site which has categories of different items. Fine, I can get the code to display a picture of each category and open up the category from each seperate picture, my problem is the sub categories.For example, The category for clocks has sub categories for wall clocks and alarm clocks. Although the code opens up the sub categories when you click on the main clock picture, it also opens up ALL sub categories. :) How do I get it to stop and only open the too clock subcats? :) I'm sure this is so straight forward and simple but I just can't seem to figure out how it's done.Thanks in advance.

Link to comment
Share on other sites

It will be easy if you can provide with a lil more details, post some code or your Database Table Structure...
Hi pulpfiction,Thanks for the quick reply.Here is some of the code...For the main product page...
<%Dim mySQL, myRSSet myRS = Server.CreateObject("ADODB.Recordset")mySQL = "SELECT CategoryID, Pic, Category, BriefDesc FROM Categories"myRS.Open mySQL, myConnDo While Not myRS.EOF  Response.Write RecToTable(myRS)myRS.MoveNextLoopResponse.Write "</p>"myRS.CloseSet myRS = Nothing%>

When you click on a product from that page, this is the code to make it display categories with no sub catergories... wasn't sure about the If Then statements...

<%Dim mySQL, myRS, CategoryIDCategoryID = CInt(Request.QueryString("CategoryID"))mySQL = "SELECT ProductID, Image, Title, Price, Description " &_"FROM Categories INNER JOIN Products " &_"ON Categories.CategoryID = Products.CategoryID " &_"WHERE Products.CategoryID = " & CategoryID & " " &_"ORDER BY ProductID"If CategoryID = "4" Then  Response.Redirect("Clocks.asp") End IfIf CategoryID = "7" Then  Response.Redirect("Garden.asp")End IfIf CategoryID = "12" Then  Response.Redirect("Kitchen.asp")End IfIf CategoryID = "19" Then  Response.Redirect("Lighting.asp")End IfIf CategoryID = "22" Then  Response.Redirect("Telephones.asp")End IfSet myRS = Server.CreateObject("ADODB.Recordset")myRS.Open mySQL, myConnDo While Not myRS.EOF  Response.Write RecToTable(myRS)  myRS.MoveNextLoopResponse.Write "</p>"  myRS.CloseSet myRS = Nothing%>

Then, so far I have been working on Clocks, so if a user clicks on the clock link they are redirected to clocks.asp which contains this code...

<%Dim mySQL, myRSSet myRS = Server.CreateObject("ADODB.Recordset")mySQL = "SELECT Category2ID, Pic2, Category2 FROM Categories2 WHERE CatergoryID = "& CategoryID &""myRS.Open mySQL, myConnDo While Not myRS.EOF  Response.Write RecToTable(myRS)myRS.MoveNextLoopResponse.Write "</p>"myRS.CloseSet myRS = Nothing%>

This is the one with the problem cos it will display every sub category and not just the two clock categories.The 3 database tables are like this:Main Category Table:Cat.jpgSub Category Table:Cat2.jpgProducts Table:prod.jpgSorry to post all this but I'm completely baffled by how to make the code stop displaying after the subcategory needed. I know it shouldn't be a Dow While EOF thing but I can't figure what it should be cos it's got to the point where I've looked at it so long I can't see anything anymore.Hope you can help! :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...