I think you're making this more complicated than it really is.
You obviously have a News table of some sort. You only need to store the date and not any month specifically (since it's inherently stored in the date).
Your query looks good as well, but it's your looping through the queries that'll have to be tweaked.
Code: Select all
<?php $result = @mysql_query("SELECT * FROM releases ORDER BY `date` DESC LIMIT 10"); ?>
Normally, when you output it'll look like this:
Code: Select all
<?php
while ($row = mysql_fetch_array($result)) {
// store the two different date "things" you want to display.
$month = date("F", $row["date"]); // eg. February
$day = date("d", $row["date"]); // eg. 04
echo $day." - ".$row["newsreleasetitle"]."<br>";
}
?>
This on its own should output:
04 - twrg
06 - ey4y
03 - 46436
17 - 4634634
but it doesn't yet output month.
Taking the same code, we can do this:
Code: Select all
<?php
while ($row = mysql_fetch_array($result)) {
// store the two different date "things" you want to display.
$month = date("F", $row["date"]); // eg. February
$day = date("d", $row["date"]); // eg. 04
echo $month."<br>";
echo $day." - ".$row["newsreleasetitle"]."<br>";
}
?>
But it will then look like:
February
04 - twrg
February
06 - ey4y
June
03 - 46436
July
17 - 4634634
Which is still not really what you want.
So what you need to do is store the $pastmonth so that you only output a specific month name once.
Code: Select all
<?php
$pastmonth = "" // so that the first month always gets outputted.
while ($row = mysql_fetch_array($result)) {
// store the two different date "things" you want to display.
$month = date("F", $row["date"]); // eg. February
$day = date("d", $row["date"]); // eg. 04
if ($pastmonth != $month) {
echo $month."<br>";
}
echo $day." - ".$row["newsreleasetitle"]."<br>";
$pastmonth = $month; // set the current month to the past month.
}
?>
This should then output:
February
04 - twrg
06 - ey4y
June
03 - 46436
July
17 - 4634634
No code has been tested. But theoretically, that's how it might work.