I'm trying to have my news display like this.
Monday, December 8th, 2002
Subject (12:00:00 PM)
News Text, blah, blah, blah
Subject (10:30:00 AM)
News text, blah blah blah
Subject (07:30:00 AM)
blah blah blah
Sunday, December 6th, 2002
Subject (9:14:00 PM)
blah blah blah
Subject (7:00:00 PM)
blah blah blah
and so on....
The problem with my current code is it only displays the most recent news post's date and will display all the news content from past dates, but not the dates associated to it. Is there a way to fix this, or are there any alternatives that might be easier to produce what I'm looking for?
$query = "SELECT DISTINCT DATE_FORMAT(newsdate,'%W, %M %D, %Y') as 'displaydate' FROM news WHERE activate='1' ORDER BY displaydate DESC";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$displaydate = $row['displaydate'];
echo '<strong>'.$displaydate.'</strong><br><hr>';
$query = "SELECT *, DATE_FORMAT(newsdate,'%r') as 'displaytime' FROM news WHERE activate='1' ORDER BY displaytime DESC";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$newsID = $row['ID'];
$subject = $row['subject'];
$newsbody = $row['newsbody'];
$pressrelease = $row['pressrelease'];
$source = $row['source'];
$sourcelink = $row['sourcelink'];
$displaytime = $row['displaytime'];
echo '<strong>'.$subject.' ('.$displaytime.')</strong><br>';
echo (nl2br($newsbody));
echo '<br><br>';
}
}