Reputation: 1974
The $pKeyArray only prints first row from the database which meets the WHERE clause, why isn't showing all rows which meets the WHERE clause, I don't want to put it in any loop, i just need is an array of P_Key of all rows.
$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);
Upvotes: 1
Views: 2537
Reputation: 1502
while($pKeyArray = mysqli_fetch_array($PKeyDetails)) {
print_r($pKeyArray);
}
Upvotes: 0
Reputation: 29414
You have to use a loop because the mysqli_fetch_*()
functions only returns one row per call.
Use this code:
$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
}
Or use mysqli_fetch_all()
:
$result = mysqli_fetch_all($PKeyDetails, MYSQLI_ASSOC); // or use MYSQLI_NUM
Upvotes: 0
Reputation: 701
You need to call mysqli_fetch_array()
for each row.
while ($pKeyArray = mysqli_fetch_array($PKeyDetails)) {
print_r($pKeyArray);
}
Upvotes: 2