[Solved] How can I create an array with all rows from database


Instead of checking the value of Popular on PHP side, you can filter directly your rows like this, and return the list of ID directly

SELECT ID FROM Products WHERE Popular = 1;

Then, you can use mysqli_fetch_array to get the results as an array directly

while ($row = mysqli_fetch_array($result)) {
  $Popular[] = $row;
}

print_r($Popular)

2

solved How can I create an array with all rows from database