Jump to content

need help pulling results using 2 tables.


a51hh

Recommended Posts

table1
ID Category SubCategory
1 100 100010
2 100 100010
3 100 100010
4 100 100020
5 100 100020
6 100 100020
7 100 100020
8 100 100030
9 100 100040

table2
ID Email First Last Address info
1 some@email.com John Smith infohere
2 another@email.com Luis Smith infohere
url.com/searchresults.php?category=100&subcategory=100010

I need to be able to pull and display according to categories and subcategories using $_GET as displayed above.

1st query runs and pulls all of the ID's according to Category and SubCategory.
The resulting IDs need to be displayed in rows using HTML formating and possibly have code to run over multiple pages.

I need to display the results from table 2 after I filter what categories from the $_GET method.

If someone can give me some code examples I would be greatful.
Link to comment
Share on other sites

you want to run a query something like this:

SELECT * FROM table1 INNER JOIN table2 ON table1.ID=table2.ID ORDER BY Category, SubCategory;

That will get you a flat table with one row for each person, ordered by category and subcategory.  Then walk through that table, saving the current category or subcategory.  If it is different from the last, print the heading.

-pnj
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.