Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Feb 2011
    Posts
    101
    Member #
    26966
    so I have a couple of codes. this first code will paginate 3 months. so For example,
    Page 1
    March 2013
    April 2013
    May 2013

    Page 2
    June 2013
    July 2013
    August 2013

    PHP Code:
    $offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
    $currMonth date('n');

    $list = array();
    $list[] = mktime(000$currMonth+$offset1);
    $list[] = mktime(000$currMonth+$offset+11);
    $list[] = mktime(000$currMonth+$offset+21);

    foreach (
    $list as $dateTS)
    {
       echo 
    date('M Y'$dateTS) . '<br />';
    }

    $prev $offset-3;
    $next $offset+3;
    echo 
    "<br><a href='?offset={$prev}'>Prev</a> <a href='?offset={$next}'>Next</a>"
    Then I have this code that senses what months are covered for an event. so lets say it has a startdate of March 15 2013 and enddate of July 7 2013. This code finds that months covered are March, April, May, June, and July

    PHP Code:
    $start = new DateTime($start);
    $end = new DateTime($end);

    $inc DateInterval::createFromDateString('first day of next month');
    $end->modify('+1 day');

    $p = new DatePeriod($start,$inc,$end);

    foreach (
    $p as $d)
     echo 
    $d->format('M') . '<br>'
    So what I need is for the two codes to work together. I need to know how to select the events from the database, then combine these two codes together. My ultimate goal is to have the events show under the proper months that they occur in. so lets say I have 2 events, "test1" 2013-03-15 to 2013-07-04 and event "test2" 2013-03-08 to 2013-04-24

    so it would look like this

    Page 1
    March 2013
    Test 1
    Test 2
    April 2013
    Test 1
    Test 2
    May 2013
    Test 1

    Page 2
    June 2013
    Test 1
    July 2013
    Test 1
    August 2013
    No events

    can anyone help with this?

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    The key is with the database (I'm assuming you're using MySQL or MySQLi?)

    Describe how you are storing your events in a database. You can query the database by a range of dates and your PREV and NEXT will be defining different ranges.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com