WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A Date Dropdown function
Categories : PHP, Date Time
Boaz Yahav
Date : Jun 10th 2005
Grade : 3 of 5 (graded 9 times)
Viewed : 26545
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?

/************************************************
** Date DropDown
**
** Author.: berber [ berber@weber-sites.com ]
** ver....: v1.00
**
** desc...: This function is used to add a date dropdown
** in a form. It will print the Year, Month and Day and
** will choose the current date as default.
** The function accepts two parameters :
**
**    $year_interval - How many years to show in the year dropdown.
**    $YearIntervalType -
**        - Past : Show only past years till this year.
**        - Future : Show only future years from this year.
**        - Both : Show both past and future years.
** The function also accepts 3 optional global parameters
** that may come from the script and override the current
** date.
************************************************/

Function ShowFromDate($year_interval,$YearIntervalType) {
GLOBAL
$day,$month,$year;

//DAY
echo "<select name=day>\n";
$i=1;
$CurrDay=date("d");
If(!IsSet(
$day)) $day=$CurrDay;
while (
$i <= 31)
      {
       If(IsSet(
$day)) {
         If(
$day == $i || ($i == substr($day,1,1) && (substr($day,0,1) == 0))) {
                  echo
"<option selected> $day\n";
                 
$i++;
         }Else{
                If(
$i<10) {
                   echo
"<option> 0$i\n";
                }Else {
                   echo
"<option> $i\n";
                }
               
$i++;
         }
       }Else {
              If(
$i == $CurrDay)
                If(
$i<10) {
                   echo
"<option selected> 0$i\n";
                }Else {
                   echo
"<option selected> $i\n";
                }
              Else {
                If(
$i<10) {
                   echo
"<option> 0$i\n";
                }Else {
                   echo
"<option> $i\n";
                }
              }
             
$i++;
       }
      }
echo
"</select>\n";

//MONTH
echo " / <select name=month>\n";
$i=1;
$CurrMonth=date("m");
while (
$i <= 12)
     {
      If(IsSet(
$month)) {
         If(
$month == $i || ($i == substr($month,1,1) && (substr($month,0,1) == 0))) {
            echo
"<option selected> $month\n";
           
$i++;
         }Else{
            If(
$i<10) {
               echo
"<option> 0$i\n";
            }Else {
               echo
"<option> $i\n";
            }
           
$i++;
         }
      }Else {
            If(
$i == $CurrMonth) {
              If(
$i<10) {
                 echo
"<option selected> 0$i\n";
              }Else {
                 echo
"<option selected> $i\n";
              }
            }Else {
              If(
$i<10){
                 echo
"<option> 0$i\n";
              }Else {
                 echo
"<option> $i\n";
              }
            }
           
$i++;
      }
}
  echo
"</select>\n";

//YEAR
 
echo " / <select name=year>\n";
 
$CurrYear=date("Y");
  If(
$YearIntervalType == "Past") {
     
$i=$CurrYear-$year_interval+1;
      while (
$i <= $CurrYear)
           {
            If(
$i == $year) {
               echo
"<option selected> $i\n";
            }ElseIf (
$i == $CurrYear && !IsSet($year)) {
               echo
"<option selected> $i\n";
            }Else {
               echo
"<option> $i\n";
            }
           
$i++;
           }
       echo
"</select>\n";
  }
  If(
$YearIntervalType == "Future") {
     
$i=$CurrYear+$year_interval;
      while (
$CurrYear < $i)
           {
            if (
$year == $CurrYear) echo "<option selected> $CurrYear\n";
              else echo
"<option> $CurrYear\n";
           
$CurrYear++;
           }
       echo
"</select>\n";
  }
  If(
$YearIntervalType == "Both") {
     
$i=$CurrYear-$year_interval+1;
      while (
$i < $CurrYear+$year_interval)
           {
            if (
$i == $CurrYear) echo "<option selected> $i\n";
              else echo
"<option> $i\n";
           
$i++;
           }
       echo
"</select>\n";
  }
}

//Ussage Example :
ShowFromDate(4,"Future");
?>



Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
A Timing Class
Categories : PHP, PHP Classes, Date Time
Simple function to return the number of days in a time span between 2 given dates.
Categories : PHP, Date Time, MySQL, Databases
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
This code consists of two parts, the first part is a .html file that uses a form to pass 3 date variables into day_of_week.php3 You input the mm/dd/yyyy of the day then it prints what day of the week that day falls on.
Categories : Date Time, PHP, Complete Programs
Functions that will format a date in either long or short format from a string.
Categories : Date Time, Strings, PHP
Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL
Script loading time
Categories : PHP, Beginner Guides, Date Time
Simple graphic clock/watch generation using gd library.
Categories : Graphics, Date Time, PHP
CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL
Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page.
Categories : PHP, Date Time, Beginner Guides, Web Design
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script