note 41272 deleted from function.date by kennyt

From: Date: Sun, 18 Jul 2004 17:23:11 +0000
Subject: note 41272 deleted from function.date by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73504@lists.php.net to get a copy of this message
Note Submitter: noy_ipunk@yahoo.com ---- 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 :)

« previous php.notes (#73504) next »