我正在从 mysql 表(作业)中获取行。在该提取中,我还从另一个表(帐户)中提取[接收帐户 api 密钥,这一切都取决于 ID_ASSOC 对工作的影响]:下面是代码
$sql = "SELECT * FROM jobs";
$query = mysqli_query($db_conx, $sql);
while($row = mysqli_fetch_assoc($query)){
echo $row['action'];
echo "<br/>";
$job_poster_id = $row['id_assoc'];
$sql = "SELECT * FROM accounts WHERE id_assoc='$job_poster_id'";
$query = mysqli_query($db_conx, $sql);
while($rows = mysqli_fetch_assoc($query)){
$username = $rows['twitter_username'];
$consumer_key = $rows['consumer_key'];
$consumer_secret = $rows['consumer_secret'];
$access_token = $rows['access_token'];
$access_token_secret = $rows['access_token_secret'];
}
echo $job_poster_id ;
echo "<br/>";
echo $twitter_username;
echo "<br/>";
echo "----------------------------------";
echo "<br/>";
}
输出:
specific-message
4
admin
----------------------------------
当我这样做时,我只得到一行输出......而且我似乎无法找出原因。我希望上面的输出重复尽可能多的行,并且它只做一行(在代码中使用帐户获取)。但是,当我在没有内部提取(帐户提取)的情况下执行此操作时,它会根据需要返回多行。为什么是这样?(下面是没有账户获取的示例代码):
$sql = "SELECT * FROM jobs";
$query = mysqli_query($db_conx, $sql);
while($row = mysqli_fetch_assoc($query)){
echo $row['action'];
echo "<br/>";
$job_poster_id = $row['id_assoc'];
echo $job_poster_id ;
echo "<br/>";
echo "----------------------------------";
echo "<br/>";
}
输出:
specific-message
4
----------------------------------
specific-message
1
----------------------------------
specific-message
2
----------------------------------