I have a page with 3 dropdowns. Team1, Team2 & Venue
When the user clicks view, I then query the DB returning results for team1 against team2 either playing at home or away or both (depending on users selection)
The code Im using to execute the query follows
if($venue = "hometeam"){
$result= " SELECT *
FROM `results`
WHERE `hometeam` = '$team1' && `awayteam` = '$team2'" or die(mysql_error());
}
else if($venue = "awayteam"){
$result = " SELECT *
FROM `results`
WHERE `awayteam` = '$team1' && `hometeam` = '$team2'"or die(mysql_error());
}
else if($venue ="all"){
$result = " SELECT *
FROM `results`
WHERE (`hometeam` = '$team1' AND `awayteam` = '$team1') OR (`hometeam` = '$team2' AND `awayteam` = '$team2')"or die(mysql_error());
}
The Problem
Regardless if the user selects venue away or both home & away the result returned is always team1 as the hometeam as you can see in the image below:
In the above example I selected Team1 as Stormers and Team2 as Sharks, I selected venue away to display Stormers record against Sharks when they are playing away from home, but as you can see from the image Stormers still gets displayed as the hometeam.
If anyone can tell me what I am doing wrong or point me in the right direction it would be greatly appreciated.
Thank you in advance