$ pKeyArray只打印满足WHERE子句的数据库的第一行,为什么不显示符合WHERE子句的所有行,我不想把它放在任何循环中,我只需要一个数组所有行的P_Key。
$getPKey = "SELECT P_Key FROM likersTable WHERE executed=0";
$PKeyDetails = mysqli_query($dbConnect,$getPKey)
or die('Some error in post id');
$pKeyArray = mysqli_fetch_array($PKeyDetails);
print_r($pKeyArray);
答案 0 :(得分:2)
您需要为每一行调用mysqli_fetch_array()
。
while ($pKeyArray = mysqli_fetch_array($PKeyDetails)) {
print_r($pKeyArray);
}
答案 1 :(得分:1)
$array = mysqli_fetch_all( $PKeyDetails);
答案 2 :(得分:0)
您必须使用循环,因为mysqli_fetch_*()
函数每次调用只返回一行。
使用此代码:
$getPKey = "SELECT P_Key FROM likersTable WHERE executed=0";
$PKeyDetails = mysqli_query($dbConnect,$getPKey)
or die('Some error in post id');
while ($row=mysqli_fetch_array($PKeyDetails))
{
// Do something with $row
}
$result = mysqli_fetch_all($PKeyDetails, MYSQLI_ASSOC); // or use MYSQLI_NUM
答案 3 :(得分:0)
while($pKeyArray = mysqli_fetch_array($PKeyDetails)) {
print_r($pKeyArray);
}