BetaONE will rise again!


 
Prev Previous Post   Next Post Next
  #1  
Old 5th Jan 04, 03:20 PM
JacKDynne's Avatar
JacKDynne JacKDynne is offline
Administrator
 
Join Date: Oct 2001
Location: The Past Through Tomorrow
Posts: 1,591
JacKDynne will become famous soon enoughJacKDynne will become famous soon enough
Send a message via MSN to JacKDynne
I am using this php code to generate a month/day/year pull down menu but I cannot set it to pull previous years from the pulldown, only the current year + . Any ideas on how to resolve this?

Here is the area in question:
Code:
// generate year drop-down echo "<select name=" . $prefix . "y>"; for ($x=$currYear; $x<($currYear+5); $x++) { $str = "<option value=$x"; &nbsp;if ($x == $currYear) &nbsp;{ &nbsp;$str .= " selected"; &nbsp;} $str .= ">" . sprintf("%04d", $x) . "</option>"; echo $str; } echo "</select>";
Here is the full code:

Code:
// function to format DATE values function fixDate($val) { // split it up into components $datearr = explode("-", $val); // create a timestamp with mktime(), format it with date() return date("d M Y", mktime(0, 0, 0, $datearr[1], $datearr[2], $datearr[0])); } // generate three list boxes for d-m-y selection function generateDateSelector($prefix="") { // month array $monthArray = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); // get current year, month and date $arr = getdate(mktime()); $currYear = $arr["year"]; $currMonth = $arr["mon"]; $currDay = $arr["mday"]; // generate date drop-down echo "<select name=" . $prefix . "d>"; for ($x=1; $x<=31; $x++) { $str = "<option value=" . sprintf("%02d", $x) . ""; &nbsp;if ($x == $currDay) &nbsp;{ &nbsp;$str .= " selected"; &nbsp;} $str .= ">" . sprintf("%02d", $x) . "</option>"; echo $str; } echo "</select>"; // generate month drop-down echo "<select name=" . $prefix . "m>"; for ($x=1; $x<=12; $x++) { $str = "<option value=" . sprintf("%02d", $x) . ""; &nbsp;if ($x == $currMonth) &nbsp;{ &nbsp;$str .= " selected"; &nbsp;} $str .= ">" . $monthArray[$x] . "</option>"; echo $str; } echo "</select>"; // generate year drop-down echo "<select name=" . $prefix . "y>"; for ($x=$currYear; $x<($currYear+5); $x++) { $str = "<option value=$x"; &nbsp;if ($x == $currYear) &nbsp;{ &nbsp;$str .= " selected"; &nbsp;} $str .= ">" . sprintf("%04d", $x) . "</option>"; echo $str; } echo "</select>"; } ?>
I tried changing this: $x<($currYear+5); to this:$x<($currYear-5); and some other variations but that does not seem to work. Any ideas while I keep researching?

Many TIA's to any who reply

/JD
__________________


Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uh, oh I have a feeling Wal-Mart might be in some trouble!! Dijital Chit Chat 0 2nd Nov 04 09:12 PM
Consistant trouble with motherboard of other hardware. Darkwolven Hardware Support 2 14th Mar 02 03:40 AM


All times are GMT +1. The time now is 03:06 PM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.