help with event calendar

I have a mysql database set up with 4 fields - id, month, day, event. The database will be filled with something like: month=Jan, day=4 and event=Meeting. All are text fields. The display will be Jan. 4: Meeting

I can set up the PHP to display the database in a unordered list. The code for this is:

<?php $result = @mysql_query("SELECT id, month, day, event FROM homecalendar"); if (!$result) { exit('

Error performing query: ' . mysql_error() . '

'); } while ($row = mysql_fetch_array($result)) { echo '
  • ' . $row['month'] . $row['day'] .': ' . $row['event'] . '
  • ' ; } ?>

    How can I limit the code to display items for only the current month and the next month?

    Hi there,

    Maybe this would help:
    [php]$month = $row[‘month’];
    $day = $row[‘day’];
    $month_test = date(“m”,strtotime($month." “.$day.” ".date(“Y”));
    if($month_test == date(“m”) || $month_test == date(“m”)+1)
    {
    echo ‘

  • ’ . $month . $day .’: ’ . $row[‘event’] . ‘
  • ’;
    }
    [/php]

    Forgive me if it doesn’t work, I haven’t tested this…

    Sponsor our Newsletter | Privacy Policy | Terms of Service