Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   MySQL (https://www.askmehelpdesk.com/forumdisplay.php?f=442)
-   -   Creating a Category List and Results (https://www.askmehelpdesk.com/showthread.php?t=144373)

  • Oct 24, 2007, 08:53 AM
    heatherdamnit
    Creating a Category List and Results
    Hi, I am trying to create a "Buyer's Guide". The first page - buyersguide.php will have a drop down menu that is populated with the categories (advertising, accounting, construction, etc.) from the table Categories. Once the user selects the category they are interested in, it will take them to a results page (buyersguideresults.php) that will list all Members who fit into the category they choose.

    So, I have 3 tables:

    1. Members:
    MemberID, CompanyName, Phone, TollFree, Fax, Address, City, State, Zip, Website, Descriptions, Email

    2. MemberCategory:
    MemberCategoryID, f_MemberID, f_CategoryID

    3. Categories:
    CategoryID, CategoryName

    First off, after I populate the drop down menu - how do I get it to take you to the results page. Once on the results page, how do I show the members info for the selected category?

    Please help! I've been working on this for weeks and just can't seem to get it! Thanks!
  • Oct 24, 2007, 08:59 AM
    ScottGem
    Getting to the results page is PHP so I can't help there. But the SQL to populate the results would look like this:

    SELECT CompanyName, Phone
    INNER JOIN ON members.MemberID = MemberCategory.MemberID
    FROM Members, MemberCategory
    WHERE CategoryID = selectedcategory

    selected category is the variable where you store the category selected on the first page.
  • Oct 24, 2007, 09:11 AM
    heatherdamnit
    Thanks Scott, but it didn't work. Somehow when the user selects a category, that category ID has to be carried over to the next page. Then it will need to match that CategoryID that is in the Categories table, with f_CategoryID from the MemberCategory table. Then match the f_MemberID from the MemberCategory with the MemberID from the Member table.

    So basically, joining 3 tables. I hope this makes sense.

    Any clue on how to do this?
  • Oct 24, 2007, 10:33 AM
    ScottGem
    No you wouldn't need to join three tables, once you capture the CatergoryID you wouldn't need the Category table. But yes, you would have to carry the Category ID over to the next page, that's what selectedcategory is. Bbut I'm not sure how to do that.

  • All times are GMT -7. The time now is 03:08 AM.