Results 1 to 2 of 2

Thread: DB date display problem

  1. #1
    Join Date
    Jan 2008
    Posts
    42
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default DB date display problem

    Ok I have this system that displays sermons from a MYSQL db. The problem is that if that date I place for the sermon is after the 13 of the month of Dec. it places it in the list before july! It's whacked. If I put it the 13 or sooner then it's fine, comes after Nov.

    You can see this problem here, down at the bottom in Dec. of 2007 and right now I'm having problems with Dec. of 08 since the current one should be the 14th since it was sun. not the 13, but since the 14 gets screwed up I can't:

    http://fscconline.org/index.php?opti...d=57&Itemid=88


    This is the code I'm using to display the dates:

    PHP Code:
    $query1 "SELECT *,
    IF (
    month_lookup.month_num < MONTH( CURDATE( ) )
    OR month_lookup.month_num = MONTH( CURDATE( ) )
    AND sermons.day < DAYOFMONTH( CURDATE( ) ) , CONCAT( sermons.month, ' ' ) , sermons.month
    ) display_month,
    IF (
    month_lookup.month_num < MONTH( CURDATE( ) )
    OR month_lookup.month_num = MONTH( CURDATE( ) )
    AND sermons.day < DAYOFMONTH( CURDATE( ) ) , month_lookup.month_num+12, month_lookup.month_num
    )*32+day prio
    FROM month_lookup, sermons
    WHERE sermons.month = month_lookup.month
    ORDER BY sermons.year DESC, prio DESC"
    ;

    $i 1;
    $lastmonth '';
    $lastyear '';
    $r mysql_query ($query1);
    $i2 0;
    while (
    $row mysql_fetch_array ($r)) {
    $i++;
    $i2++;

    $day   $row['day'];
    $month $row['month'];
    $display_month $row['display_month'];
    $y1 $row['year'];

    if(
    $lastmonth != $month OR $lastyear != $y1)
            {
                
    $lastmonth $month;
                
    $lastyear $y1;
                if (
    $i2 1) {
                echo 
    "<tr><td>&nbsp;</td></tr>";
                }
                echo 
    "<tr><td colspan=4 bgcolor=#96B831><strong>&nbsp;$display_month $y1</strong></td></tr>";
                
    $i "0";

            } 

  2. #2
    Join Date
    Jan 2008
    Posts
    42
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Does anyone have any insight on this problem? I figure it's just a problem with the math for the date that I'm using, am I right and how do I fix this if it is?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •