Date code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeroen

    Date code

    Hi,

    I'm searching but not finding :(

    I need the code that creates automatic the days in a month

    So like for this month, it creates the days in this format 01-Oct, 02-Oct,
    ....

    This should be used in a form so when opening the page, automatic all the
    days of that specific month
    are listed, and when saving those dates are saved in the database (MySql)

    Monday is the start of the week and the weekends (sat-sun) should be marked
    in another collor.

    I hope someone can help me with this, because I'm trying to make this for
    about 2 weeks now, and all I've got are errors :s

    Many Thx,

    Jeroen

    ----




  • tk

    #2
    Re: Date code

    On Thu, 23 Oct 2003 12:25:03 +0000, Jeroen wrote:
    [color=blue]
    > Hi,
    >
    > I'm searching but not finding :(
    >
    > I need the code that creates automatic the days in a month
    >
    > So like for this month, it creates the days in this format 01-Oct, 02-Oct,
    > ...
    >
    > This should be used in a form so when opening the page, automatic all the
    > days of that specific month
    > are listed, and when saving those dates are saved in the database (MySql)
    >
    > Monday is the start of the week and the weekends (sat-sun) should be marked
    > in another collor.
    >
    > I hope someone can help me with this, because I'm trying to make this for
    > about 2 weeks now, and all I've got are errors :s
    >
    > Many Thx,[/color]


    Have a look on <http://www.phpbuilder. com/> for "calendar". There's a
    tutorial (although not all of the code is great) on building a calendar..
    this should help you work out what code is used to work out what days for
    this month (ie: 28 / 29 for Feb, 30 for September, 31 for October etc) and
    then you can use strtotime() and / or strftime() to format the date how
    you like (see <http://www.php.net/> for descriptions on these functions if
    unsure).


    HTH =)



    Regards,

    Ian


    XP reply, FU: comp.lang.php

    --
    ----------------------------------------------
    o _ And God saw that it was good.
    (\_|_) And God blessed them, saying "Be fruitful and multiply"
    T> ] | Genesis 1:21,22 | Mark Ludwig - LBBoCV

    Comment

    • Jeroen

      #3
      Re: Date code


      "tk" <tk@WINDOZEdigi serv.net> schreef in bericht
      news:pan.2003.1 0.23.11.36.47.9 4430@hybris.dig iserv.net...[color=blue]
      > On Thu, 23 Oct 2003 12:25:03 +0000, Jeroen wrote:
      >[color=green]
      > > Hi,
      > >
      > > I'm searching but not finding :(
      > >
      > > I need the code that creates automatic the days in a month
      > >
      > > So like for this month, it creates the days in this format 01-Oct,[/color][/color]
      02-Oct,[color=blue][color=green]
      > > ...
      > >
      > > This should be used in a form so when opening the page, automatic all[/color][/color]
      the[color=blue][color=green]
      > > days of that specific month
      > > are listed, and when saving those dates are saved in the database[/color][/color]
      (MySql)[color=blue][color=green]
      > >
      > > Monday is the start of the week and the weekends (sat-sun) should be[/color][/color]
      marked[color=blue][color=green]
      > > in another collor.
      > >
      > > I hope someone can help me with this, because I'm trying to make this[/color][/color]
      for[color=blue][color=green]
      > > about 2 weeks now, and all I've got are errors :s
      > >
      > > Many Thx,[/color]
      >
      >
      > Have a look on <http://www.phpbuilder. com/> for "calendar". There's a
      > tutorial (although not all of the code is great) on building a calendar..
      > this should help you work out what code is used to work out what days for
      > this month (ie: 28 / 29 for Feb, 30 for September, 31 for October etc) and
      > then you can use strtotime() and / or strftime() to format the date how
      > you like (see <http://www.php.net/> for descriptions on these functions if
      > unsure).
      >
      >
      > HTH =)
      >
      >
      >
      > Regards,
      >
      > Ian
      >
      >
      > XP reply, FU: comp.lang.php
      >
      > --
      > ----------------------------------------------
      > o _ And God saw that it was good.
      > (\_|_) And God blessed them, saying "Be fruitful and multiply"
      > T> ] | Genesis 1:21,22 | Mark Ludwig - LBBoCV
      >[/color]

      Hey Tk,

      I have already follow that tutorial for the callendar :)
      But I don't understand some parts of their code, and infact, I don't need a
      callendar.
      Ok, from the callendar I can start making the date, that's true.

      What I had was something like this

      <tr>

      <td><?php echo date("d-M", strtotime($user["date"])) ?>&nbsp;</td>
      <td><?php echo date("l", strtotime($user["date"])) ?>&nbsp;</td>
      <tr>

      But this still takes the date out of the database.(but the output was
      already fine :))
      example : http://arcbelgium.be-hosted.be/januari_2003.php


      Now I'm bussy with the page to fill this data in


      but I can't get it working :(

      So in the edit page the date's and days should be auto generated (code hours
      and remarks that are plain text fields to submit)
      and when submitting the page all data is stored in the db.

      this is how far I'm now:

      <?php
      $dbserver = "localhost" ;
      $dbnaam = "xxx";

      $link = mysql_connect ($dbserver,"xxx ","xxxxx") or die("There is no
      connection to the mySQL-server" . $dbserver . ".");
      $db = mysql_select_db ($dbnaam,$link) or die("Cannot open table " . $dbnaam .
      " on mySQL-server " . $dbserver . ".");

      if(isSet($act) && $act == "del"){
      mysql_query("DE LETE FROM Januari WHERE id= ".$id.";");
      unset($act);
      echo mysql_errno() . ": " . mysql_error() . "\n";
      }


      if(isSet($act) && $act == "dodjst"){
      mysql_query("UP DATE Januari SET
      client='".$clie nt."',Responsib le_Manager='".$ resp_manager."' ,consultant='". $
      consultant."',d ay='".$day."',h ours=".$hours." ,remarks=".$rem arks.",code=".$ c
      ode.",date=".$d ate." WHERE id= ".$id.";");
      echo mysql_errno() . ": " . mysql_error() . "\n";
      }

      if(isSet($act) && $act == "doadd"){
      mysql_query("IN SERT INTO Januari VALUES
      (0,'".$userid." ','".$client."' ,'".$resp_manag er."','".$consu ltant."','".$da y
      .."','".$hours. "','".$remarks. "','".$code."', '".$date."');") ;
      echo mysql_errno() . ": " . mysql_error() . "\n";
      }


      $result = mysql_query("SE LECT * FROM Januari WHERE 1 order by date;");


      ?>
      <table class="tabelap" >
      <?php

      ?>





      <table width="73%" border="1">
      <tr>
      <td width="20%" bgcolor="#ffff0 0"><strong>Date </strong></td>
      <td width="20%" bgcolor="#ffff0 0"><strong>D ay</strong></td>
      <td width="20%" bgcolor="#ffff0 0"><strong>Code </strong></td>
      <td width="14%" bgcolor="#ffff0 0"><strong>Hour s</strong></td>
      <td width="26%" bgcolor="#ffff0 0"><strong>Rema rks</strong></td>
      </tr>


      <?php

      if(isSet($act) && $act == "add"){
      ?>

      <?php
      for($i=0;$i<mys ql_num_rows($re sult);$i++){
      $user = mysql_fetch_arr ay($result);
      if(isSet($act) && $act == "djst"){
      if($id == $user["id"]){
      ?>


      <form METHOD="POST" action="januari _2003_edit.php? act=add">
      <input type="hidden" name="act" value="doadd">
      <tr>

      <td><?php echo date("d-M", strtotime($user["date"])) ?>&nbsp;</td>
      <td><?php echo date("l", strtotime($user["date"])) ?>&nbsp;</td>
      <td><select name="code" size="1">
      <option value="A6">06-14</option>
      <option value="R7">07-15</option>
      <option value="R10">10-18</option>
      <option value="P14">14-22</option>
      <option value="N22">22-06</option>
      <option value="H">Natio nal Holiday</option>
      <option value="V">Vacat ion</option>
      <option value="R">Recup eration Day</option>
      <option value="S">Sickn ess</option>
      <option value="F">Famil y Related Absence</option>
      <option value="L">Legal Absence</option>
      </select></td>
      <td><input type="text" name="hours" value="" size="1"></td>
      <td><input type="text" name="remarks" value="" size="15"></td>
      <td><input type="submit" name="ok" value="SUBMIT"> </td>

      </tr>


      </form>

      <?php
      }
      }
      }
      }

      ?>


      <?php

      ?>

      </table>
      <tr></tr><br><br>
      <?
      $normal = " 'A6', 'R7', 'R10', 'P14', 'N22' ";
      $absence = " 'H', 'V', 'R', 'S', 'F', 'L' ";

      $result = mysql_query("SE LECT sum(hours) FROM Januari WHERE code IN
      ($normal)");
      $normalhours = mysql_result($r esult,0);

      $result = mysql_query("SE LECT sum(hours) FROM Januari WHERE code IN
      ($absence)");
      $absencehours = mysql_result($r esult,0);

      $totalhours = $normalhours + $absencehours;

      echo "Working hours: $normalhours <BR>Hours of absence: $absencehours<B R>";
      echo "Total hours: $totalhours<br> ";
      ?>


      Comment

      • Jeroen

        #4
        Re: Date code


        "Jeroen" <info@nospam. be-be-hosted> schreef in bericht
        news:sePlb.1008 60$MW6.4593801@ phobos.telenet-ops.be...[color=blue]
        >
        > "tk" <tk@WINDOZEdigi serv.net> schreef in bericht
        > news:pan.2003.1 0.23.11.36.47.9 4430@hybris.dig iserv.net...[color=green]
        > > On Thu, 23 Oct 2003 12:25:03 +0000, Jeroen wrote:
        > >[color=darkred]
        > > > Hi,
        > > >
        > > > I'm searching but not finding :(
        > > >
        > > > I need the code that creates automatic the days in a month
        > > >
        > > > So like for this month, it creates the days in this format 01-Oct,[/color][/color]
        > 02-Oct,[color=green][color=darkred]
        > > > ...
        > > >
        > > > This should be used in a form so when opening the page, automatic all[/color][/color]
        > the[color=green][color=darkred]
        > > > days of that specific month
        > > > are listed, and when saving those dates are saved in the database[/color][/color]
        > (MySql)[color=green][color=darkred]
        > > >
        > > > Monday is the start of the week and the weekends (sat-sun) should be[/color][/color]
        > marked[color=green][color=darkred]
        > > > in another collor.
        > > >
        > > > I hope someone can help me with this, because I'm trying to make this[/color][/color]
        > for[color=green][color=darkred]
        > > > about 2 weeks now, and all I've got are errors :s
        > > >
        > > > Many Thx,[/color]
        > >
        > >
        > > Have a look on <http://www.phpbuilder. com/> for "calendar". There's a
        > > tutorial (although not all of the code is great) on building a[/color][/color]
        calendar..[color=blue][color=green]
        > > this should help you work out what code is used to work out what days[/color][/color]
        for[color=blue][color=green]
        > > this month (ie: 28 / 29 for Feb, 30 for September, 31 for October etc)[/color][/color]
        and[color=blue][color=green]
        > > then you can use strtotime() and / or strftime() to format the date how
        > > you like (see <http://www.php.net/> for descriptions on these functions[/color][/color]
        if[color=blue][color=green]
        > > unsure).
        > >
        > >
        > > HTH =)
        > >
        > >
        > >
        > > Regards,
        > >
        > > Ian
        > >
        > >
        > > XP reply, FU: comp.lang.php
        > >
        > > --
        > > ----------------------------------------------
        > > o _ And God saw that it was good.
        > > (\_|_) And God blessed them, saying "Be fruitful and multiply"
        > > T> ] | Genesis 1:21,22 | Mark Ludwig - LBBoCV
        > >[/color]
        >
        > Hey Tk,
        >
        > I have already follow that tutorial for the callendar :)
        > But I don't understand some parts of their code, and infact, I don't need[/color]
        a[color=blue]
        > callendar.
        > Ok, from the callendar I can start making the date, that's true.
        >
        > What I had was something like this
        >
        > <tr>
        >
        > <td><?php echo date("d-M", strtotime($user["date"])) ?>&nbsp;</td>
        > <td><?php echo date("l", strtotime($user["date"])) ?>&nbsp;</td>
        > <tr>
        >
        > But this still takes the date out of the database.(but the output was
        > already fine :))
        > example : http://arcbelgium.be-hosted.be/januari_2003.php
        >
        >
        > Now I'm bussy with the page to fill this data in
        > http://arcbelgium.be-hosted.be/januari_2003_edit.php
        >
        > but I can't get it working :(
        >
        > So in the edit page the date's and days should be auto generated (code[/color]
        hours[color=blue]
        > and remarks that are plain text fields to submit)
        > and when submitting the page all data is stored in the db.
        >
        > this is how far I'm now:
        >
        > <?php
        > $dbserver = "localhost" ;
        > $dbnaam = "xxx";
        >
        > $link = mysql_connect ($dbserver,"xxx ","xxxxx") or die("There is no
        > connection to the mySQL-server" . $dbserver . ".");
        > $db = mysql_select_db ($dbnaam,$link) or die("Cannot open table " . $dbnaam[/color]
        ..[color=blue]
        > " on mySQL-server " . $dbserver . ".");
        >
        > if(isSet($act) && $act == "del"){
        > mysql_query("DE LETE FROM Januari WHERE id= ".$id.";");
        > unset($act);
        > echo mysql_errno() . ": " . mysql_error() . "\n";
        > }
        >
        >
        > if(isSet($act) && $act == "dodjst"){
        > mysql_query("UP DATE Januari SET
        >[/color]
        client='".$clie nt."',Responsib le_Manager='".$ resp_manager."' ,consultant='". $[color=blue]
        >[/color]
        consultant."',d ay='".$day."',h ours=".$hours." ,remarks=".$rem arks.",code=".$ c[color=blue]
        > ode.",date=".$d ate." WHERE id= ".$id.";");
        > echo mysql_errno() . ": " . mysql_error() . "\n";
        > }
        >
        > if(isSet($act) && $act == "doadd"){
        > mysql_query("IN SERT INTO Januari VALUES
        >[/color]
        (0,'".$userid." ','".$client."' ,'".$resp_manag er."','".$consu ltant."','".$da y[color=blue]
        > ."','".$hours." ','".$remarks." ','".$code."',' ".$date."') ;");
        > echo mysql_errno() . ": " . mysql_error() . "\n";
        > }
        >
        >
        > $result = mysql_query("SE LECT * FROM Januari WHERE 1 order by date;");
        >
        >
        > ?>
        > <table class="tabelap" >
        > <?php
        >
        > ?>
        >
        >
        >
        >
        >
        > <table width="73%" border="1">
        > <tr>
        > <td width="20%" bgcolor="#ffff0 0"><strong>Date </strong></td>
        > <td width="20%" bgcolor="#ffff0 0"><strong>D ay</strong></td>
        > <td width="20%" bgcolor="#ffff0 0"><strong>Code </strong></td>
        > <td width="14%" bgcolor="#ffff0 0"><strong>Hour s</strong></td>
        > <td width="26%" bgcolor="#ffff0 0"><strong>Rema rks</strong></td>
        > </tr>
        >
        >
        > <?php
        >
        > if(isSet($act) && $act == "add"){
        > ?>
        >
        > <?php
        > for($i=0;$i<mys ql_num_rows($re sult);$i++){
        > $user = mysql_fetch_arr ay($result);
        > if(isSet($act) && $act == "djst"){
        > if($id == $user["id"]){
        > ?>
        >
        >
        > <form METHOD="POST" action="januari _2003_edit.php? act=add">
        > <input type="hidden" name="act" value="doadd">
        > <tr>
        >
        > <td><?php echo date("d-M", strtotime($user["date"])) ?>&nbsp;</td>
        > <td><?php echo date("l", strtotime($user["date"])) ?>&nbsp;</td>
        > <td><select name="code" size="1">
        > <option value="A6">06-14</option>
        > <option value="R7">07-15</option>
        > <option value="R10">10-18</option>
        > <option value="P14">14-22</option>
        > <option value="N22">22-06</option>
        > <option value="H">Natio nal Holiday</option>
        > <option value="V">Vacat ion</option>
        > <option value="R">Recup eration Day</option>
        > <option value="S">Sickn ess</option>
        > <option value="F">Famil y Related Absence</option>
        > <option value="L">Legal Absence</option>
        > </select></td>
        > <td><input type="text" name="hours" value="" size="1"></td>
        > <td><input type="text" name="remarks" value="" size="15"></td>
        > <td><input type="submit" name="ok" value="SUBMIT"> </td>
        >
        > </tr>
        >
        >
        > </form>
        >
        > <?php
        > }
        > }
        > }
        > }
        >
        > ?>
        >
        >
        > <?php
        >
        > ?>
        >
        > </table>
        > <tr></tr><br><br>
        > <?
        > $normal = " 'A6', 'R7', 'R10', 'P14', 'N22' ";
        > $absence = " 'H', 'V', 'R', 'S', 'F', 'L' ";
        >
        > $result = mysql_query("SE LECT sum(hours) FROM Januari WHERE code IN
        > ($normal)");
        > $normalhours = mysql_result($r esult,0);
        >
        > $result = mysql_query("SE LECT sum(hours) FROM Januari WHERE code IN
        > ($absence)");
        > $absencehours = mysql_result($r esult,0);
        >
        > $totalhours = $normalhours + $absencehours;
        >
        > echo "Working hours: $normalhours <BR>Hours of absence:[/color]
        $absencehours<B R>";[color=blue]
        > echo "Total hours: $totalhours<br> ";
        > ?>
        >
        >[/color]

        no one who can help? :( I'm getting really depri about this and I'm a total
        php n00b as you can see ...


        Comment

        • Jerry Gitomer

          #5
          Re: Date code

          On Thu, 23 Oct 2003 11:25:03 +0000, Jeroen wrote:
          [color=blue]
          > Hi,
          >
          > I'm searching but not finding :(
          >
          > I need the code that creates automatic the days in a month
          >
          > So like for this month, it creates the days in this format 01-Oct,
          > 02-Oct, ...[color=green]
          > > This should be used in a form so when opening the page, automatic all
          > > the[/color]
          > days of that specific month
          > are listed, and when saving those dates are saved in the database
          > (MySql)
          >
          > Monday is the start of the week and the weekends (sat-sun) should be
          > marked in another collor.
          >
          > I hope someone can help me with this, because I'm trying to make this
          > for about 2 weeks now, and all I've got are errors :s
          >
          > Many Thx,
          >
          > Jeroen
          >
          > ----[/color]

          Jeroen,

          I don't have a worked out example in PHP for Zoeller's (sp?) algorithm for
          determining the day of the week, but I did find a web site page that has
          several algorithms, one of which I think will meet your needs.

          The URL is:


          No, this will not give you a calendar in the form you are seeking, but it
          will give you a means of determining the day of the week of the first day
          of the month. You can then build your own array for the month. If you
          can use HTML for your output you can then use the array to load a table
          which can be viewed or printed.

          HTH

          Jerry

          Comment

          • Tim Van Wassenhove

            #6
            Re: Date code

            ["Followup-To:" header set to alt.php.sql.]
            On 2003-10-23, Jeroen <info@nospam. be-be-hosted> wrote:[color=blue]
            > Hi,
            >
            > I'm searching but not finding :(
            >
            > I need the code that creates automatic the days in a month
            >
            > So like for this month, it creates the days in this format 01-Oct, 02-Oct,
            > ...
            >
            > This should be used in a form so when opening the page, automatic all the
            > days of that specific month
            > are listed, and when saving those dates are saved in the database (MySql)
            >
            > Monday is the start of the week and the weekends (sat-sun) should be marked
            > in another collor.
            >
            > I hope someone can help me with this, because I'm trying to make this for
            > about 2 weeks now, and all I've got are errors :s[/color]

            I don't know what you've been doing last 2 weeks, but when i don't know
            how to do something i start with consulting the manual.
            (http://www.php.net/manual/nl/ref.datetime.php)
            In the user comments there are more than enough hints...

            --
            esllicious

            Comment

            • Jeroen

              #7
              Re: Date code


              "Jerry Gitomer" <jgitomer@erols .com> schreef in bericht
              news:pan.2003.1 0.23.14.14.25.7 91491@erols.com ...[color=blue]
              > On Thu, 23 Oct 2003 11:25:03 +0000, Jeroen wrote:
              >[color=green]
              > > Hi,
              > >
              > > I'm searching but not finding :(
              > >
              > > I need the code that creates automatic the days in a month
              > >
              > > So like for this month, it creates the days in this format 01-Oct,
              > > 02-Oct, ...[color=darkred]
              > > > This should be used in a form so when opening the page, automatic all
              > > > the[/color]
              > > days of that specific month
              > > are listed, and when saving those dates are saved in the database
              > > (MySql)
              > >
              > > Monday is the start of the week and the weekends (sat-sun) should be
              > > marked in another collor.
              > >
              > > I hope someone can help me with this, because I'm trying to make this
              > > for about 2 weeks now, and all I've got are errors :s
              > >
              > > Many Thx,
              > >
              > > Jeroen
              > >
              > > ----[/color]
              >
              > Jeroen,
              >
              > I don't have a worked out example in PHP for Zoeller's (sp?) algorithm for
              > determining the day of the week, but I did find a web site page that has
              > several algorithms, one of which I think will meet your needs.
              >
              > The URL is:
              > http://www.m2c3.com/alpocs/Library/A...nuts_part1.htm
              >
              > No, this will not give you a calendar in the form you are seeking, but it
              > will give you a means of determining the day of the week of the first day
              > of the month. You can then build your own array for the month. If you
              > can use HTML for your output you can then use the array to load a table
              > which can be viewed or printed.
              >
              > HTH
              >
              > Jerry[/color]

              Hey Jerry,

              Thx for the link even it's written for VB it can help a hand to understand
              the calculation.

              I already was thinking about something like this:

              $d1 = mktime(0,0,0,da te('m'),1,date( 'Y'));
              $d2 = mktime(0,0,0,da te('m')+1,1,dat e('Y'));
              $days = (($d2-$d1) / (24 * 3600));

              and the rest I'm still thinking off :)

              thx!


              Comment

              • Jeroen

                #8
                Re: Date code


                "Tim Van Wassenhove" <euki@pi.be> schreef in bericht
                news:bn8o3l$v7a lm$1@ID-188825.news.uni-berlin.de...[color=blue]
                > ["Followup-To:" header set to alt.php.sql.]
                > On 2003-10-23, Jeroen <info@nospam. be-be-hosted> wrote:[color=green]
                > > Hi,
                > >
                > > I'm searching but not finding :(
                > >
                > > I need the code that creates automatic the days in a month
                > >
                > > So like for this month, it creates the days in this format 01-Oct,[/color][/color]
                02-Oct,[color=blue][color=green]
                > > ...
                > >
                > > This should be used in a form so when opening the page, automatic all[/color][/color]
                the[color=blue][color=green]
                > > days of that specific month
                > > are listed, and when saving those dates are saved in the database[/color][/color]
                (MySql)[color=blue][color=green]
                > >
                > > Monday is the start of the week and the weekends (sat-sun) should be[/color][/color]
                marked[color=blue][color=green]
                > > in another collor.
                > >
                > > I hope someone can help me with this, because I'm trying to make this[/color][/color]
                for[color=blue][color=green]
                > > about 2 weeks now, and all I've got are errors :s[/color]
                >
                > I don't know what you've been doing last 2 weeks, but when i don't know
                > how to do something i start with consulting the manual.
                > (http://www.php.net/manual/nl/ref.datetime.php)
                > In the user comments there are more than enough hints...
                >
                > --
                > esllicious[/color]

                Hey Tim,

                I have looked a lot of times in the manual, but I have no knowledge of php,
                this
                is the first time I'm working with it and I don't find it something easy :)

                Also I have no program skills, I'm a sys admin, not a programmer, so sorry
                for asking
                stupid questions!


                Comment

                • Peter

                  #9
                  Re: Date code

                  [color=blue]
                  > no one who can help? :( I'm getting really depri about this and I'm a[/color]
                  total[color=blue]
                  > php n00b as you can see ...[/color]

                  ever heard of editing out irrelevent parts of posts instead of making people
                  scroll down all that way to see the reply


                  Comment

                  Working...