php - Query multiple tables - display Team Name based on Team ID -


my tables structures are

`tblteam` (`teamid`, `teamname`) values (1,'india'), (2,'pakistan'), (3,'brazil') (4,'poland');  `tblmatch` (`matchid`, `matchdate`, `matchstart`, `matchend`, `team1id`, `team2id`) values (1, '19-11-2014', '12:00:00', '13:00:00', 1, 2), (2, '19-11-2014', '13:10:00', '14:10:00', 4, 3), (3, '19-11-2014', '14:20:00', '15:20:00', 1, 3), (4, '19-11-2014', '15:30:00', '16:30:00', 4, 2), (5, '20-11-2014', '10:00:00', '11:00:00', 1, 4), (6, '20-11-2014', '11:10:00', '12:10:00', 3, 4); 

insert tblscore (scoreid, teamid, matchid, score) values (1, 1, 1, 5), (2, 2, 1, 6), (3, 4, 2, 15), (4, 3, 2, 26);

i want display team name of (team1id, team2id) on 19-11-2014 there 4 matches

 in php output should  time                   : between : 12:00:00 - 13:00:00      india v/s pakistan 13:10:00 - 14:10:00      poland v/s brazil  
select m.matchid, m.matchdate, m.matchstart, m.matchend, m.team1id, m.team2id,  t.teamid, t.teamname  tblmatch m, tblteam t m.matchdate ='$todayis' order m.matchdate 

php

while($row=mysqli_fetch_array($res)){     $mid= $row['matchid'];     $mdd = $row['matchdate'];     $t1 = $row['team1id'];     $t2 = $row['team2id'];     $t1n = $row['teamname'];        echo $t1n . " v/s  . " $t1n ;     }  score query not work    $query="select   m.matchid,   m.matchdate,   m.team1id,   m.team2id,   s.teamid,  s.matchid,  t1.teamname teamname1,   t2.teamname teamname2,  t1s.score team1score,  t2s.score team2score  tblmatch m  join tblteam t1  on m.team1id = t1.teamid join tblteam t2  on m.team2id =      t2.teamid  join tblscore s on m.team1id = t1s.teamid join tblscore s on m.team1id = t1s.teamid  join   tblscore s on m.team2id = t2s.teamid s.matchid=$mid  "; 

you can join match table result twice team table extract information of match , name of each team. after need concatenate data fetch database in php.

select      m.matchid,      m.matchdate,      m.matchstart,      m.matchend,      m.team1id,      m.team2id,      t1.teamname teamname1,      t2.teamname teamname2 tblmatch m join tblteam t1     on m.team1id = t1.teamid join tblteam t2     on m.team2id = t2.teamid 

php code:

while($row=mysqli_fetch_array($res)){     $mid= $row['matchid'];     $mdd = $row['matchdate'];     $t1 = $row['team1id'];     $t2 = $row['team2id'];     $t1n = $row['teamname1'];      $t2n = $row['teamname2'];       echo $t1n . " v/s  . " $t2n ; } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -