Hi,
I'm trying to sort my posts so that they are grouped and seperated for every month. For example all december posts will be grouped togther and given a header with the name december, and etc for the other months.
<?php
include ('connect.php');
$months = array(1 => "january", 2 => "february", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
for($i = 12; $i > 0; $i--)
{
echo "<h2>" .$months[$i] ."</h2>";
(row 29->)$sql = mysql_query("SELECT DATE_FORMAT(date, '%n') AS manad, date, title FROM news_posts WHERE MONTH(manad)= '$i'");
while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
echo $row['title'];
echo $row['date'];
}
}
?>
All I get is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/alexofsweden/public_html/archive.php on line 29.
If there is another solution to my problem that is easier, share it please