I have be struggling to turn the below while loop into a foreach loop with no result, so I am asking for help here on how to do this.

$query = "Select * from TIME_TABLE Where
Extract(month from DATE_FIELD ) = DATE_FORMAT(NOW(), '%c')
and
Extract(day from DATE_FIELD ) = DATE_FORMAT(NOW(), '%e')
order by DATE_FIELD, DESCRIPTION";
$result = $mysqli->query($query);

while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
    $dbItems .=  "<item> <record_num>" . $row['RECORD_NUM'] . "</record_num>" .
        "<date_field>" .   $row['DATE_FIELD'] . "</date_field>" .
        "<description>" .  $row['DESCRIPTION'] . "</description> </item>";
}

I placed this in the wrong group. I am moving this to PHP.
Sorry!

I placed this in the wrong group. I am moving this to PHP.
Sorry!

Next time please click on "Flag Bad Post" and write message like "Please move to PHP" and assign moderator will take care of it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.