我有2张桌子
表(1):列名为'games_id','home_team_fk','away_team_fk'等的'游戏'
表(2):列名为'teams_id','teams_name'等的'团队'。
'home_team_fk'='teams_id'
目前我的陈述只会检索'teams_id'。这是我目前的代码。我想生成一个SQL语句,它将显示'teams_name'而不是'home_team_fk'。
<?php
$season = $_GET['season'];
$stmt = $DBcon->prepare("SELECT * FROM games WHERE games_season = '$season'");
$stmt->execute();
?>
<?php if($stmt->rowCount() > 0) { while($row=$stmt->FETCH(PDO::FETCH_ASSOC)) { ?>
<?php print($row['home_team_fk']); ?> vs <?php print($row['away_team_fk']); ?>
<?php } } else { ?>
No games recorded yet.
<?php } ?>
答案 0 :(得分:0)
以下查询将返回给定游戏季节的主队名称和客队名称。它使用两次队伍来获得主队和客队的球队名称。
$.post("ajax/modQtyModels",
{
modelId: $(this).closest('tr').children('td.idmodel').text(),
qty: $(this).closest('tr').children('td.editQty').text()
},
function(data) {
var myResult = data;
if(myResult['success'] == "true") {
$(that).closest('tr').children('td.editQty').addClass("success");
} else {
$(that).closest('tr').children('td.editQty').addClass("danger");
alert("No changes were made");
}
},
'json'
});