Support

Account

Home Forums Add-ons Repeater Field Create a table from a repeater

Solving

Create a table from a repeater

  • Hi!
    I need to create a table from a repeater in this way:

    Name: John Doe
    Lesson—–January-February -March- April-May -June- July-August- September-October -November-December

    lesson 1—-2—-3—-0—-5—-3—-8—-2—-0—-12—5—-2

    I have a custom post type called teachers. In custom post type each teacher can select a lesson (select field) and a date (date field). Each teacher select a lesson and the lesson can be repeated several times each month.
    The objetive is build a table with the name of the lesson and how many times the lesson was gave in each month.

    Please check the example image:

    http://www.hellovictor.com/wp-content/uploads/table_teachers_and_lessons.png

    Thank you in advance!!

  • should be possible,
    but definitely a complex nested loop that contains date-splitting and count is needed for that. also you probably need to build a own array before you echo something.

    my advise is build it at your own, or find/pay someone that can do it for you.

    the only help i can give is this tip:
    build a array and use this php-functions => date, strtotime, foreach, count

    //to get month or year
    $get_date = get_field('datefield');
    $get_date_month = date('m', strtotime($get_date));
    $get_date_year = date('Y', strtotime($get_date));
    
    //build a array out of lesson, year, month and day, something like that
    // $array[$lession][$year][$month][$date]
    // then use a foreach loop with count on month to build your table
  • Thanks for your time and for your answer!
    I’ll try to fix it following your instructions.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Create a table from a repeater’ is closed to new replies.