基本上我从 table1 中提取一个 ID,使用该 ID 在 table2 中查找站点 ID,然后需要使用数组中的站点 ID,内爆,并查询 table3 以获取站点名称。我无法正确地对数组进行内爆,首先出现错误,然后使用了 while 循环。
使用 while 循环,输出只是说: Array
$mysqli = mysqli_connect("server", "login", "pass", "db");
$sql = "SELECT MarketID FROM marketdates WHERE Date = '2010-04-04 00:00:00' AND VenueID = '2'";
$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
$dates_id = mysqli_fetch_assoc ( $result );
$comma_separated = implode(",", $dates_id);
echo $comma_separated; //This Returns 79, which is correct.
$sql = "SELECT SIteID FROM bookings WHERE BSH_ID = '1' AND MarketID = '$comma_separated'";
$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
// This is where my problems start
$SIteID = array();
while ($newArray = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$SIteID[] = $newArray[SIteID];
}
$locationList = implode(",",$SIteID);
?>
基本上我需要做的是正确地将查询结果移动到一个数组中,我可以在第三个查询中使用它来从 table3 中提取名称。