SkyRanger Posted March 2, 2012 Share Posted March 2, 2012 Hello, not sure if lack of sleep or just staring at code too long. This is what I have: while($rowy = mysql_fetch_array( $resulty )) { mpdate = YYYY-MM-DD $date = $rowy['mpdate']; $year = explode('-', $date); $month = date("F", mktime(0, 0, 0, $year[1])); ?> <?php echo $year[0]; ?> <br> <?php echo $month; ?> <br> <?php echo $rowy['mptitle']; } ?> I figure if I use: if ($year[0] == date('Y"){ echo month and entry stuff } but I keep getting errors. What I am trying to do is sort everything out into year month and day ie: 2012 March Entry 1 Entry 2 February Entry 1 Entry 2 Entry 3 etc... This is what I am getting 2012 March Entry 1 2012 March Entry 2 2012 February Entry 1 etc... Is there a way to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/258123-sort-by-year-month-entry/ Share on other sites More sharing options...
SkyRanger Posted March 2, 2012 Author Share Posted March 2, 2012 No looking at it, it might now even be possible with the way I have the date. I may have to break it up into different cells and pull it out one at a time and then combine them out put everything for the year and month Quote Link to comment https://forums.phpfreaks.com/topic/258123-sort-by-year-month-entry/#findComment-1323168 Share on other sites More sharing options...
SkyRanger Posted March 2, 2012 Author Share Posted March 2, 2012 Ok. Thought I fixed the problem but guess not. Changed the tables to work a little easier but still not working. This is the problem I am having. Table Data: mpid mpyear mpmonth mpday mptitle 4 2012 3 2 Text stuff here 3 2012 3 1 Day 1 stuff here 2 2012 2 28 Feb stuff here 1 2011 12 27 First post test here So what I am trying to do is sort out per year month ie: 2012 3 Text stuff here Day 1 stuff here 2 Feb stuff here 2011 12 First post test here This is what I have tried with now luck just repeats year month title for each entry $resulty = mysql_query("SELECT * FROM monsterpost order by mpid desc limit 1") or die(mysql_error()); while($rowy = mysql_fetch_array( $resulty )) { Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/258123-sort-by-year-month-entry/#findComment-1323193 Share on other sites More sharing options...
PFMaBiSmAd Posted March 3, 2012 Share Posted March 3, 2012 Ummm. I'm not sure why you marked this thread as being solved, but I replied in the other thread you started for this exact same problem, how you detect and output the information the way you want it to be. Don't start new threads for the same issue. Quote Link to comment https://forums.phpfreaks.com/topic/258123-sort-by-year-month-entry/#findComment-1323477 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.