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 [email protected] John Smith infohere
2 [email protected] 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
https://forums.phpfreaks.com/topic/26294-need-help-pulling-results-using-2-tables/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.