newb Posted July 6, 2010 Share Posted July 6, 2010 i have a problem..my posts are showing up like this: July 6: post message July 6: post message July 6: post message im trying to get it like this: July 6: post message post message post message how do i group them like this in all in one post? Quote Link to comment Share on other sites More sharing options...
msaz87 Posted July 6, 2010 Share Posted July 6, 2010 Show some code Quote Link to comment Share on other sites More sharing options...
shortysbest Posted July 6, 2010 Share Posted July 6, 2010 In your mysql query where you're echoing out the posts, have you tried adding "GROUP BY date" date would be what ever the column in your database with the date is called Quote Link to comment Share on other sites More sharing options...
newb Posted July 6, 2010 Author Share Posted July 6, 2010 i dont think that works because in my database there is stored UNIX timestamps... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 6, 2010 Share Posted July 6, 2010 Not certain, but the MySQL FROM_UNIXTIME() function might be able to help you sort this out. Quote Link to comment Share on other sites More sharing options...
newb Posted July 7, 2010 Author Share Posted July 7, 2010 i am trying to acheive this: http://www.breakfastpolitics.com/ can someone help me out please.. :-\ Quote Link to comment Share on other sites More sharing options...
shortysbest Posted July 7, 2010 Share Posted July 7, 2010 i am trying to acheive this: http://www.breakfastpolitics.com/ can someone help me out please.. :-\ post your code please? Quote Link to comment Share on other sites More sharing options...
newb Posted July 7, 2010 Author Share Posted July 7, 2010 $query = mysql_query("SELECT * FROM av_items ORDER BY av_items.date DESC LIMIT 20"); while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; $date = $row['date']; $message = $row['message']; $entry_date = date("Ymd", $date); if ($entry_date !== $called_date) { echo '<h1 class="topic">'.av_date($date) .'</h1>'; echo $message; $called_date=$entry_date; } } Quote Link to comment Share on other sites More sharing options...
shortysbest Posted July 7, 2010 Share Posted July 7, 2010 Have you tried this? : $query = mysql_query("SELECT * FROM av_items GROUP BY month(date) ORDER BY av_items.date DESC LIMIT 20"); while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; $date = $row['date']; $message = $row['message']; $entry_date = date("Ymd", $date); if ($entry_date !== $called_date) { echo '<h1 class="topic">'.av_date($date) .'</h1>'; echo $message; $called_date=$entry_date; } } Quote Link to comment Share on other sites More sharing options...
newb Posted July 7, 2010 Author Share Posted July 7, 2010 im trying to group by day not month..didnt help Quote Link to comment Share on other sites More sharing options...
shortysbest Posted July 7, 2010 Share Posted July 7, 2010 im trying to group by day not month..didnt help whoops sorry, replace month with day. Quote Link to comment Share on other sites More sharing options...
newb Posted July 7, 2010 Author Share Posted July 7, 2010 didnt change anything Quote Link to comment Share on other sites More sharing options...
sasa Posted July 7, 2010 Share Posted July 7, 2010 move line echo $message; after if block Quote Link to comment Share on other sites More sharing options...
newb Posted July 8, 2010 Author Share Posted July 8, 2010 nope. anyone? Quote Link to comment Share on other sites More sharing options...
sasa Posted July 8, 2010 Share Posted July 8, 2010 try $query = mysql_query("SELECT * FROM av_items ORDER BY av_items.date DESC LIMIT 20"); //remove GROUP BY part while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; $date = $row['date']; $message = $row['message']; $entry_date = date("Ymd", $date); if ($entry_date !== $called_date) { echo '<h1 class="topic">'.av_date($date) .'</h1>'; //echo $message; $called_date=$entry_date; }echo $message, "<br />\n"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.