I am trying to echo only certain rows of a PHP MySQL array.
I've gone through many iterations, but can't seem to figure it out.
<?php
$conn = new mysqli("SERVER", "user", "password", "dbname");
$sql = "
SELECT
POSTDATE,
MEMBERS_ALL,
MEMBERS_ACTIVE,
FROM
daily_numbers
";
$result = $conn->query($sql);
$conn->close();
while($row = $result->fetch_assoc()) {
if ($row["MEMBERS_ALL"] == 600) {
echo "Date: " . $row["POSTDATE"] . ", Members All: " . $row["MEMBERS_ALL"] . ", Members Active: " .$row["MEMBERS_ACTIVE"];
}
};
while($row = $result->fetch_assoc()) {
if ($row["MEMBERS_ALL"] == 705) {
echo "Date: " . $row["POSTDATE"] . ", Members All: " . $row["MEMBERS_ALL"] . ", Members Active: " .$row["MEMBERS_ACTIVE"];
}
};
?>
The example above will only show the first while/if statement (== 600), however I can not get it to echo the second while/if statement (== 705).
I would like to be able to echo the array multiple times using different constraints (I don't want to run the SQL statement more than once).