I want to add a new line in order to group dates within a foreach
loop.
Example:
2015-11-05
2015-11-05
2015-11-07
2015-11-10
2015-11-1
Both answers provided by Mureinik and Subin are good. But you also have the option to do the following
SELECT datetime_published,count(*) as count,`id_visitor`,`id_category`,`datetime_published`,`datetime_edited`,`data_content` FROM table group by `datetime_published` order by `datetime_published` desc
for ($i = 1; $i <= $row['count']; $i++) {
echo $row['datetime_published']." ".$row['data_content'] .'
';
}
echo "
";
Complete Solution spoiler
";
if ($results=mysqli_query($con,$var))
{
// Fetch one and one row
while ($rows=mysqli_fetch_assoc($results))
{
print $rows['data_subject']. " " . $rows['data_content'];
echo "
";
}
}
echo "
";
}
}
echo "
";
// Free result set
mysqli_free_result($result);
mysqli_close($con);
?>