Probably not the best description for a title but I really couldn't think of anything. What I want to happen is that I can create a query that selects the type from listings using the userID as a relationship and then selecting the town.
TABLE listings
saleID userID type description
1 23 clothing nice clothing
2 45 clothing More nice Clothing
TABLE users
userID country county town
23 uk county townname1
24 uk county townname2
The variables are set in the url as a get eg) ?type=clothing&town=townname2
if (!isset($type)){
$query = "SELECT * FROM listings";
}
if (isset($type)) {
$query = "SELECT * FROM listings WHERE type = '{$type}'";
}
This is the bit i'm stuck on I want to get all listings with the variable $type 'clothing' and then select from users with the town of the variable $town
if (isset($town)) {
$query = "SELECT users.town listings.userID listings.type FROM listings
WHERE type = '{$type}'
INNER JOIN users
ON users.town = '{$town}'";
}
Hope I've explained this well enough to understand. Please help me with this last query