Hi, I am trying to run the following query, but it's only displaying the records where `home` is $team, but it's not displaying the records where `away` is $team
Here is my code
[PHP]$data = mysql_query("SE LECT DATE_FORMAT(Dat e,'%d/%m/%Y') AS UKDate , TIME_FORMAT(Tim e,'%H:%i') AS TimeNew , `Home` , `Away` , `Final` , `Status` , `FT` , `Att` , `ID` FROM matches WHERE `Away` OR `Home` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci AND `Competition` LIKE CONVERT( _utf8 '$comp%' USING latin1 ) COLLATE latin1_swedish_ ci AND date BETWEEN '$datefrom' AND '$dateto' ORDER BY Date DESC") [/PHP]
I have also tried the code below, this displays the teams properly (although it's not sorting them by date order, it's but a load of away ones first, then a few home, then away, then a load of home ones :S) but it then ignores the other parts (e.g. certain competition or date range)
[PHP]$data = mysql_query("SE LECT DATE_FORMAT(Dat e,'%d/%m/%Y') AS UKDate , TIME_FORMAT(Tim e,'%H:%i') AS TimeNew , `Home` , `Away` , `Final` , `Status` , `FT` , `Att` , `ID` FROM matches WHERE `Away` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci OR `Home` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci AND `Competition` LIKE CONVERT( _utf8 '$comp%' USING latin1 ) COLLATE latin1_swedish_ ci AND date BETWEEN '$datefrom' AND '$dateto' ORDER BY Date DESC")[/PHP]
I have also tried changing $team to $hometeam and $awayteam and using AND, then putting the like part in for each of them, but then it looks for the home and away teams being the same in each record which obviously can't happen and if I put OR it ignores the other part of it like competition :S It might be really simple but I have tried different combinations and can’t see why it won’t work!
Thanks
Zack :)
Here is my code
[PHP]$data = mysql_query("SE LECT DATE_FORMAT(Dat e,'%d/%m/%Y') AS UKDate , TIME_FORMAT(Tim e,'%H:%i') AS TimeNew , `Home` , `Away` , `Final` , `Status` , `FT` , `Att` , `ID` FROM matches WHERE `Away` OR `Home` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci AND `Competition` LIKE CONVERT( _utf8 '$comp%' USING latin1 ) COLLATE latin1_swedish_ ci AND date BETWEEN '$datefrom' AND '$dateto' ORDER BY Date DESC") [/PHP]
I have also tried the code below, this displays the teams properly (although it's not sorting them by date order, it's but a load of away ones first, then a few home, then away, then a load of home ones :S) but it then ignores the other parts (e.g. certain competition or date range)
[PHP]$data = mysql_query("SE LECT DATE_FORMAT(Dat e,'%d/%m/%Y') AS UKDate , TIME_FORMAT(Tim e,'%H:%i') AS TimeNew , `Home` , `Away` , `Final` , `Status` , `FT` , `Att` , `ID` FROM matches WHERE `Away` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci OR `Home` LIKE CONVERT( _utf8 '$team' USING latin1 ) COLLATE latin1_swedish_ ci AND `Competition` LIKE CONVERT( _utf8 '$comp%' USING latin1 ) COLLATE latin1_swedish_ ci AND date BETWEEN '$datefrom' AND '$dateto' ORDER BY Date DESC")[/PHP]
I have also tried changing $team to $hometeam and $awayteam and using AND, then putting the like part in for each of them, but then it looks for the home and away teams being the same in each record which obviously can't happen and if I put OR it ignores the other part of it like competition :S It might be really simple but I have tried different combinations and can’t see why it won’t work!
Thanks
Zack :)
Comment