Jump to content

Sort by year month entry


SkyRanger

Recommended Posts

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?

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.