我的代码有问题。我对我的第二张桌子有同样的回应。在第一个中,它会转到下一列。第二张表的相同响应
PHP
$sql = "SELECT * from schedule s, matches m GROUP BY s.id";
$con = mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);
$result = mysqli_query($con,$sql);
$response = array();
while($row=mysqli_fetch_array($result))
{
array_push($response, array("start"=>$row[4],"end"=>$row[5],"venue"=>$row[6], "teamone"=>$row[8], "teamtwo"=>$row[9],
"s_name"=>$row[17]));
}
echo json_encode (array("schedule_response"=>$response));
mysqli_close($con);
?>
这是我收到的响应。正如你可以看到teamone一样,teamtwo和s_name都是一样的。它没有得到第二列的值。
{"schedule_response":[
{"start":"2016-11-23 00:00:00","end":"2016-11-24 00:00:00","venue":"bbbb",
"teamone":"aaa","teamtwo":"hehe","s_name":"sssss"},
{"start":"2016-11-22 00:00:00","end":"2016-11-23 00:00:00","venue":"aaaaaaa",
"teamone":"aaa","teamtwo":"hehe","s_name":"sssss"}]}
你需要添加'where s.m_id = m.m_id' – Blinkydamo
当我添加where s.m_id = m.m_id – orange
'SELECT * from schedule as s,matches as m where s.m_id = m.m_id GROUP BY s.id'。如果你在's.m_id'中有一个与'm.m_id'相匹配的id,那么它应该拉一些东西。 – Blinkydamo