Showing a weekly program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martien van Wanrooij

    Showing a weekly program

    Maybe I haven't been able to find the answer in Google because I didn't know
    how it is called exactly but I am still puzzling about an easy solution to
    update weekly the services of the local church. It should be done without
    mySql. The ideal situation would be that php could read the appropiate data
    from a text file, so the text file can be easily edited and uploaded by one
    of the church's voluntary workers.
    The text file could look like

    Zaterdag 25 oktober.
    10:00 Pastor P. Jansen
    11:00 Pastor W. Dirksen
    Zondag 26 oktober.
    12:00 Pastor P. Dirks
    Zaterdag 1 november
    10:00 Pastor J.Hendriks
    Zondag 2 november
    9:00 Pastor G. de Vries

    I would like a function that reads the whole tekst and only publishes the
    services for the next weekend. I think I will be able to make a function
    that converts the date written in Dutch to an English string and than this
    will be converted to a real date, but how can I make php show not only the
    date but also the services for that weekend?

    If there is info on the web about this, please tell me what keywords I
    should enter in Google.

    Thanks for any reaction
    Martien van Wanrooij


  • Geoff Berrow

    #2
    Re: Showing a weekly program

    I noticed that Message-ID: <sUBmb.2426$2o2 .18092@amstwist 00> from
    Martien van Wanrooij contained the following:
    [color=blue]
    >Maybe I haven't been able to find the answer in Google because I didn't know
    >how it is called exactly but I am still puzzling about an easy solution to
    >update weekly the services of the local church. It should be done without
    >mySql. The ideal situation would be that php could read the appropiate data
    >from a text file, so the text file can be easily edited and uploaded by one
    >of the church's voluntary workers.[/color]

    It's a shame if you don't have access to MySQL. I have written an event
    management system that does use MySql and will send you a link to the
    test pages for you to try it by email. Updating the events is done via
    a web interface. On the web page, the events automatically update
    themselves. Events which are in the past are simply not shown.


    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Ben

      #3
      Re: Showing a weekly program

      "Martien van Wanrooij" <info@martienva nwanrooij.nl> wrote in message news:<sUBmb.242 6$2o2.18092@ams twist00>...[color=blue]
      > Maybe I haven't been able to find the answer in Google because I didn't know
      > how it is called exactly but I am still puzzling about an easy solution to
      > update weekly the services of the local church. It should be done without
      > mySql. The ideal situation would be that php could read the appropiate data
      > from a text file, so the text file can be easily edited and uploaded by one
      > of the church's voluntary workers.
      > The text file could look like
      >
      > Zaterdag 25 oktober.
      > 10:00 Pastor P. Jansen
      > 11:00 Pastor W. Dirksen
      > Zondag 26 oktober.
      > 12:00 Pastor P. Dirks
      > Zaterdag 1 november
      > 10:00 Pastor J.Hendriks
      > Zondag 2 november
      > 9:00 Pastor G. de Vries
      >
      > I would like a function that reads the whole tekst and only publishes the
      > services for the next weekend. I think I will be able to make a function
      > that converts the date written in Dutch to an English string and than this
      > will be converted to a real date, but how can I make php show not only the
      > date but also the services for that weekend?
      >
      > If there is info on the web about this, please tell me what keywords I
      > should enter in Google.
      >
      > Thanks for any reaction
      > Martien van Wanrooij[/color]

      Maybe you could use the function

      switch

      case

      Comment

      • Nikolai Chuvakhin

        #4
        Re: Showing a weekly program

        "Martien van Wanrooij" <info@martienva nwanrooij.nl> wrote
        in message news:<sUBmb.242 6$2o2.18092@ams twist00>...[color=blue]
        >
        > The ideal situation would be that php could read the appropiate data
        > from a text file, so the text file can be easily edited and uploaded
        > by one of the church's voluntary workers.
        > The text file could look like
        >
        > Zaterdag 25 oktober.
        > 10:00 Pastor P. Jansen
        > 11:00 Pastor W. Dirksen
        > Zondag 26 oktober.
        > 12:00 Pastor P. Dirks
        > Zaterdag 1 november
        > 10:00 Pastor J.Hendriks
        > Zondag 2 november
        > 9:00 Pastor G. de Vries
        >
        > I would like a function that reads the whole tekst and only publishes
        > the services for the next weekend.[/color]

        Let me try to help, but you'll have to excuse me for my truly
        atrocious Dutch... :)

        Let's say you made a slight modification to your file format:

        Dadel: Zaterdag 25 oktober.
        10:00 Pastor P. Jansen
        11:00 Pastor W. Dirksen
        Dadel: Zondag 26 oktober.
        12:00 Pastor P. Dirks
        Dadel: Zaterdag 1 november
        10:00 Pastor J.Hendriks
        Dadel: Zondag 2 november
        9:00 Pastor G. de Vries

        Then you could do something like this:

        function parseServiceSch edule() {
        $monthsE = array ('January', 'February', 'March',
        'April', 'May', 'June',
        'July', 'August', 'September',
        'October', 'November', 'December');
        $monthsD = array ('januari', 'februari', 'maart',
        'april', 'mei', 'juni',
        'juli', 'augustus', 'september',
        'oktober', 'november', 'december');
        $daysE = array ('Sunday', 'Monday', 'Tuesday', 'Wednesday',
        'Thursday', 'Friday', 'Saturday');
        $daysD = array ('zondag', 'maandag', 'dinsdag', 'woensdag',
        'donderdag', 'vrijdag', 'zaterdag');
        $schedule = file ('rooster.txt') ;
        $output = false;
        foreach ($schedule as $line) {
        if ($dateD = strstr ($line, 'Dadel:')) {
        $output = false;
        $dateE = str_replace ($monthsD, $monthsE, $dateD);
        $dateE = str_replace ($daysD, $daysE, $dateE);
        $timestamp = strtotime ($dateE);
        $target = strtotime ('next Saturday 12:00 AM');
        if (($timestamp > $target) and
        (($timestamp - $target) < (48*60*60))) {
        $output = true;
        }
        }
        if ($output) {
        echo $line;
        }
        }
        }

        Cheers,
        NC

        Comment

        • Nikolai Chuvakhin

          #5
          Re: Showing a weekly program

          ....Just sent a reply and realized there were a couple of bugs
          in it... Here's the updated (and tested) version:

          function parseServiceSch edule() {
          $monthsE = array ('January', 'February', 'March',
          'April', 'May', 'June',
          'July', 'August', 'September',
          'October', 'November', 'December');
          $monthsD = array ('januari', 'februari', 'maart',
          'april', 'mei', 'juni',
          'juli', 'augustus', 'september',
          'oktober', 'november', 'december');
          $daysE = array ('Sunday', 'Monday', 'Tuesday', 'Wednesday',
          'Thursday', 'Friday', 'Saturday');
          $daysD = array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag',
          'Donderdag', 'Vrijdag', 'Zaterdag');
          $schedule = file ('rooster.txt') ;
          $output = false;
          foreach ($schedule as $line) {
          if ($dateD = strstr ($line, 'Dadel:')) {
          $output = false;
          $dateE = str_replace ('Dadel:', '', $dateD);
          $dateE = str_replace ($monthsD, $monthsE, $dateE);
          $dateE = str_replace ($daysD, $daysE, $dateE);
          $timestamp = strtotime ($dateE);
          $target = strtotime ('next Saturday 12:00 AM');
          if (($timestamp >= $target) and
          (($timestamp - $target) < (48*60*60))) {
          $output = true;
          }
          }
          if ($output) {
          echo $line;
          }
          }
          }

          Cheers,
          NC

          Comment

          • Martien van Wanrooij

            #6
            Re: Showing a weekly program


            "Nikolai Chuvakhin" <nc@iname.com > schreef in bericht
            news:32d7a63c.0 310252326.d3c2c d7@posting.goog le.com...[color=blue]
            > ...Just sent a reply and realized there were a couple of bugs[/color]
            Thank you Nikita, this is really very helpfull. My major problem was the
            fact that the date has to be evaluated on these lines were there *is" really
            a date in it and I was puzzling how to avoid evaluation of lines without the
            date.[color=blue]
            > $schedule = file ('rooster.txt') ;[/color]
            I didn't know that accessing a file is that easy. Most documentation talks
            about fopen() and similar functions.[color=blue]
            > $dateE = str_replace ($monthsD, $monthsE, $dateE);
            > $dateE = str_replace ($daysD, $daysE, $dateE);[/color]
            Another facility that was new for me: the replacing can obviously done by
            searching two arrays.
            Thanks again,
            Martien van Wanrooij


            Comment

            • Martien van Wanrooij

              #7
              Re: Showing a weekly program


              "Martien van Wanrooij" <info@martienva nwanrooij.nl> schreef in bericht
              news:s7Pmb.2487 $2o2.18108@amst wist00...[color=blue]
              > Thank you Nikita, this is really very helpfull.[/color]
              Oops, I mean Nikolai ! :-) Sorry...


              Comment

              Working...