note 41272 added to function.date

From: Date: Mon, 05 Apr 2004 12:03:21 +0000
Subject: note 41272 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-67647@lists.php.net to get a copy of this message
Calendar, one date within a textfield, with "next" and "previous" date button. Using database. Hi, I have this simple code that might be usefull to be inserted in a software or smt like that. this is some kind of a side scroll calendar. Every time the user enter, today's date is updated in the db. file : calendar.php <?php $today = date("Y-m-d"); include("../functions/dbconnect.php"); $query_date="update date set date='$today'"; mysql_query($query_date)or die(mysql_error()); echo $today ; $date = $today ; echo "<form action=calendar1.php method=post>"; echo "<input type=submit name=submit value=prev>"; echo "<input type=text size=15 name=date value=$date>"; echo "<input type=submit name=submit value=next>"; echo "</form>"; ?> Then the real thing start. file: calendar1.php <?php //Begin here include("../functions/dbconnect.php"); echo $date; $data = explode('-',$date); $jaar = $data[0]; $maand = $data[1]; $dag = $data[2]; if($submit == "prev") { $date = date("Y-m-d", mktime(0, 0, 0, $maand , $dag-1 , $jaar)); $query_prev="update date set date='$date'"; mysql_query($query_prev)or die(mysql_error()); } if($submit == "next") { $date = date("Y-m-d", mktime(0, 0, 0, $maand , $dag+1 , $jaar)); $query_next="update date set date='$date'"; mysql_query($query_next)or die(mysql_error()); } echo "<p> FORM <p>"; echo "<form action=calendar2.php method=post>"; echo "<input type=submit name=submit value=prev>"; echo "<input type=text size=15 name=date value= "; echo $date ; echo ">"; echo "<input type=submit name=submit value=next>"; echo "</form>"; ?> file : calendar2.php <?php //Begin here include("../functions/dbconnect.php"); echo $date; $data = explode('-',$date); $jaar = $data[0]; $maand = $data[1]; $dag = $data[2]; if($submit == "prev") { $date = date("Y-m-d", mktime(0, 0, 0, $maand , $dag-1 , $jaar)); $query_prev="update date set date='$date'"; mysql_query($query_prev)or die(mysql_error()); } if($submit == "next") { $date = date("Y-m-d", mktime(0, 0, 0, $maand , $dag+1 , $jaar)); $query_next="update date set date='$date'"; mysql_query($query_next)or die(mysql_error()); } echo "<p> FORM <p>"; echo "<form action=calendar1.php method=post>"; echo "<input type=submit name=submit value=prev>"; echo "<input type=text size=15 name=date value= "; echo $date ; echo ">"; echo "<input type=submit name=submit value=next>"; echo "</form>"; ?> I hope this might be usefull some day for some one :) ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41272 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41272&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41272&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67647) next »