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:Sub Category Table:Products Table:Sorry 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!