是否可以获取数组的结果并将其与另一个表 ID 连接以输出 ID 的名称?
这是数组的输出: Array ( [0] => 3 [1] => 1 [2] => 2 )
这是mysql:
SELECT *
FROM
meet
INNER JOIN location
ON meet.meetLoc = location.locID
LEFT JOIN team ON meet.meetTeams = team.teamID
ORDER BY meetDate ASC
这是 PHP,但是,当我需要“Bob : Sally : Sue”时,它只输出“3 : 1 : 2”:
$teams = explode(", ", $row_rsCurMeet['meetTeams']);
$tmp = array();
foreach ($teams as $team)
$tmp[] = $team;
echo implode(' : ',$tmp);
我也试过这个,但它返回“鲍勃:鲍勃:鲍勃”
$team_id = $row_rsCurMeet['teamID'];
$team_name = $row_rsCurMeet['teamName'];
$team = $row_rsCurMeet['teamName'];
$teams = explode(", ", $row_rsCurMeet['meetTeams']);
foreach ($teams as $key => $value) {
$key = $team_id;
$value = $team_name;
print_r ($value);
}
有什么想法吗?我的头因为撞墙而疼。谢谢!
SAMPLE DATA
Table meet Table team
meetID meetTeams teamID teamName
1 3, 1, 2 1 Sally
2 2, 3, 1 2 Sue
3 1, 3, 2 3 Bob
请忽略位置信息,因为这不是问题。