Date code

This is a discussion on Date code within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I'm searching but not finding :( I need the code that creates automatic the days in a month So ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-23-2003
Jeroen
 
Posts: n/a
Default 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

----

www.be-hosted.be


Reply With Quote
  #2 (permalink)  
Old 10-23-2003
Jeroen
 
Posts: n/a
Default Re: Date code


"tk" <tk@WINDOZEdigiserv.net> schreef in bericht
news:pan.2003.10.23.11.36.47.94430@hybris.digiserv .net...
> On Thu, 23 Oct 2003 12:25:03 +0000, Jeroen wrote:
>
> > 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,

>
>
> 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
>


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
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 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("DELETE FROM Januari WHERE id= ".$id.";");
unset($act);
echo mysql_errno() . ": " . mysql_error() . "\n";
}


if(isSet($act) && $act == "dodjst"){
mysql_query("UPDATE Januari SET
client='".$client."',Responsible_Manager='".$resp_ manager."',consultant='".$
consultant."',day='".$day."',hours=".$hours.",rema rks=".$remarks.",code=".$c
ode.",date=".$date." WHERE id= ".$id.";");
echo mysql_errno() . ": " . mysql_error() . "\n";
}

if(isSet($act) && $act == "doadd"){
mysql_query("INSERT INTO Januari VALUES
(0,'".$userid."','".$client."','".$resp_manager."' ,'".$consultant."','".$day
.."','".$hours."','".$remarks."','".$code."','".$d ate."');");
echo mysql_errno() . ": " . mysql_error() . "\n";
}


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


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

?>





<table width="73%" border="1">
<tr>
<td width="20%" bgcolor="#ffff00"><strong>Date</strong></td>
<td width="20%" bgcolor="#ffff00"><strong>Day</strong></td>
<td width="20%" bgcolor="#ffff00"><strong>Code</strong></td>
<td width="14%" bgcolor="#ffff00"><strong>Hours</strong></td>
<td width="26%" bgcolor="#ffff00"><strong>Remarks</strong></td>
</tr>


<?php

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

<?php
for($i=0;$i<mysql_num_rows($result);$i++){
$user = mysql_fetch_array($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">National Holiday</option>
<option value="V">Vacation</option>
<option value="R">Recuperation Day</option>
<option value="S">Sickness</option>
<option value="F">Family 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("SELECT sum(hours) FROM Januari WHERE code IN
($normal)");
$normalhours = mysql_result($result,0);

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

$totalhours = $normalhours + $absencehours;

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


Reply With Quote
  #3 (permalink)  
Old 10-23-2003
Jeroen
 
Posts: n/a
Default Re: Date code


"Jeroen" <info@nospam.be-be-hosted> schreef in bericht
news:sePlb.100860$MW6.4593801@phobos.telenet-ops.be...
>
> "tk" <tk@WINDOZEdigiserv.net> schreef in bericht
> news:pan.2003.10.23.11.36.47.94430@hybris.digiserv .net...
> > On Thu, 23 Oct 2003 12:25:03 +0000, Jeroen wrote:
> >
> > > 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,

> >
> >
> > 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
> >

>
> 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
> 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

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("DELETE FROM Januari WHERE id= ".$id.";");
> unset($act);
> echo mysql_errno() . ": " . mysql_error() . "\n";
> }
>
>
> if(isSet($act) && $act == "dodjst"){
> mysql_query("UPDATE Januari SET
>

client='".$client."',Responsible_Manager='".$resp_ manager."',consultant='".$
>

consultant."',day='".$day."',hours=".$hours.",rema rks=".$remarks.",code=".$c
> ode.",date=".$date." WHERE id= ".$id.";");
> echo mysql_errno() . ": " . mysql_error() . "\n";
> }
>
> if(isSet($act) && $act == "doadd"){
> mysql_query("INSERT INTO Januari VALUES
>

(0,'".$userid."','".$client."','".$resp_manager."' ,'".$consultant."','".$day
> ."','".$hours."','".$remarks."','".$code."','".$da te."');");
> echo mysql_errno() . ": " . mysql_error() . "\n";
> }
>
>
> $result = mysql_query("SELECT * FROM Januari WHERE 1 order by date;");
>
>
> ?>
> <table class="tabelap">
> <?php
>
> ?>
>
>
>
>
>
> <table width="73%" border="1">
> <tr>
> <td width="20%" bgcolor="#ffff00"><strong>Date</strong></td>
> <td width="20%" bgcolor="#ffff00"><strong>Day</strong></td>
> <td width="20%" bgcolor="#ffff00"><strong>Code</strong></td>
> <td width="14%" bgcolor="#ffff00"><strong>Hours</strong></td>
> <td width="26%" bgcolor="#ffff00"><strong>Remarks</strong></td>
> </tr>
>
>
> <?php
>
> if(isSet($act) && $act == "add"){
> ?>
>
> <?php
> for($i=0;$i<mysql_num_rows($result);$i++){
> $user = mysql_fetch_array($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">National Holiday</option>
> <option value="V">Vacation</option>
> <option value="R">Recuperation Day</option>
> <option value="S">Sickness</option>
> <option value="F">Family 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("SELECT sum(hours) FROM Januari WHERE code IN
> ($normal)");
> $normalhours = mysql_result($result,0);
>
> $result = mysql_query("SELECT sum(hours) FROM Januari WHERE code IN
> ($absence)");
> $absencehours = mysql_result($result,0);
>
> $totalhours = $normalhours + $absencehours;
>
> echo "Working hours: $normalhours <BR>Hours of absence:

$absencehours<BR>";
> echo "Total hours: $totalhours<br>";
> ?>
>
>


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


Reply With Quote
  #4 (permalink)  
Old 10-23-2003
Jerry Gitomer
 
Posts: n/a
Default Re: Date code

On Thu, 23 Oct 2003 11:25:03 +0000, Jeroen wrote:

> 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
>
> ----


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
Reply With Quote
  #5 (permalink)  
Old 10-23-2003
Tim Van Wassenhove
 
Posts: n/a
Default Re: Date code

["Followup-To:" header set to alt.php.sql.]
On 2003-10-23, Jeroen <info@nospam.be-be-hosted> wrote:
> 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


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
Reply With Quote
  #6 (permalink)  
Old 10-23-2003
Jeroen
 
Posts: n/a
Default Re: Date code


"Jerry Gitomer" <jgitomer@erols.com> schreef in bericht
news:pan.2003.10.23.14.14.25.791491@erols.com...
> On Thu, 23 Oct 2003 11:25:03 +0000, Jeroen wrote:
>
> > 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
> >
> > ----

>
> 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


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,date('m'),1,date('Y'));
$d2 = mktime(0,0,0,date('m')+1,1,date('Y'));
$days = (($d2-$d1) / (24 * 3600));

and the rest I'm still thinking off :)

thx!


Reply With Quote
  #7 (permalink)  
Old 10-23-2003
Jeroen
 
Posts: n/a
Default Re: Date code


"Tim Van Wassenhove" <euki@pi.be> schreef in bericht
news:bn8o3l$v7alm$1@ID-188825.news.uni-berlin.de...
> ["Followup-To:" header set to alt.php.sql.]
> On 2003-10-23, Jeroen <info@nospam.be-be-hosted> wrote:
> > 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

>
> 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


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!


Reply With Quote
  #8 (permalink)  
Old 10-25-2003
Peter
 
Posts: n/a
Default Re: Date code


> no one who can help? :( I'm getting really depri about this and I'm a

total
> php n00b as you can see ...


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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0