473,805 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I remove Year from this code ?

8 New Member
If I want to remove the drop down for the year will that make the birthday not show on the calendar? If it looks like it is ok to remove it what can be removed?? What should it look like?


[PHP]function date_selection( $default_date=" ", $field_names=ar ray("user_birth day_month", "user_birthday_ day", "user_birthday_ year"), $labels=1)
// Returns date selection as a drop-down menu, if field names are omitted birthday fields are used
{
// Determine start date
if ($default_date)
{
if (strpos($defaul t_date, "-"))
{
list($year, $month, $day) = explode("-", $default_date);
if (substr($year, 0, 1) == "s")
{
$year = substr($year, 1);
$start_date = ($year > date("Y")) ? date("Y") : $year;
}
}
else if (substr($defaul t_date, 0, 1) == "s")
$start_date = substr($default _date, 1, 4);
}

if (!$start_date)
$start_date = 1900;

$months = array(
lg("month_janua ry"),
lg("month_febru ary"),
lg("month_march "),
lg("month_april "),
lg("month_may") ,
lg("month_june" ),
lg("month_july" ),
lg("month_augus t"),
lg("month_septe mber"),
lg("month_octob er"),
lg("month_novem ber"),
lg("month_decem ber"));

if ($labels)
{
$month_list = sprintf('<OPTIO N VALUE="00">%s</OPTION>%s', lg("month"), "\n");
$day_list = sprintf('<OPTIO N VALUE="00">%s</OPTION>%s', lg("day"), "\n");
$year_list = sprintf('<OPTIO N VALUE="0000">%s </OPTION>%s', lg("year"), "\n");
}

for ($i = 0; $i < 12; $i++)
{
($i == $month - 1) ? $is_selected = " SELECTED" : $is_selected = "";
$month_list .= sprintf(' <OPTION VALUE="%s"%s>%s </OPTION>%s', $i + 1, $is_selected, $months[$i], "\n");
}

for ($i = 1; $i <= 31; $i++)
{
($day == $i) ? $is_selected = " SELECTED" : $is_selected = "";
$day_list .= sprintf(' <OPTION VALUE="%02d"%s> %02d</OPTION>%s', $i, $is_selected, $i, "\n");
}

(($field_names[0] == "user_birthday_ month") or (strlen($defaul t_date) <= 5)) ?
$current_year = date("Y") : $current_year = 2037;

for ($i = $start_date; $i <= $current_year; $i++)
{
($year == $i) ? $is_selected = " SELECTED" : $is_selected = "";
$year_list .= sprintf(' <OPTION VALUE="%s"%s>%s </OPTION>%s', $i, $is_selected, $i, "\n");
}

// Sort fields according to date format
$parts = preg_split('/\-|\s+|,/', USER_DATE_FORMA T);
foreach ($parts as $part)
if (in_array($part , array("m", "M", "F")))
$sorted_output[] = array($field_na mes[0], $month_list);

else if (in_array($part , array("d", "j", "jS")))
$sorted_output[] = array($field_na mes[1], $day_list);

else if ($part == "Y")
$sorted_output[] = array($field_na mes[2], $year_list);

$date_field1 = (strpos($sorted _output[0][0], '"') !== false) ? $sorted_output[0][0] : '"' . $sorted_output[0][0] . '"';
$date_field2 = (strpos($sorted _output[1][0], '"') !== false) ? $sorted_output[1][0] : '"' . $sorted_output[1][0] . '"';
$date_field3 = (strpos($sorted _output[2][0], '"') !== false) ? $sorted_output[2][0] : '"' . $sorted_output[2][0] . '"';

return sprintf('<SELEC T NAME=%s ID="wgui_%s">%s </SELECT>' . "\n" .
'<SELECT NAME=%s ID="wgui_%s">%s </SELECT>' . "\n" .
'<SELECT NAME=%s ID="wgui_%s">%s </SELECT>' . "\n",
$date_field1, str_replace('"' , '', $date_field1), $sorted_output[0][1],
$date_field2, str_replace('"' , '', $date_field2), $sorted_output[1][1],
$date_field3, str_replace('"' , '', $date_field3), $sorted_output[2][1]);
}[/PHP]
Jun 8 '07 #1
0 1187

Sign in to post your reply or Sign up for a free account.

Similar topics

14
4766
by: Protoman | last post by:
Hi!!! I need some help on a project I'm that calculates leap years; I'm getting errors that I have no idea what they mean; here's the code: #include <iostream> #include <cstdlib> using namespace std; class Year { public:
9
2423
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
4
2728
by: Chuy08 | last post by:
If I have a multdimensional array like so: $records = array( array('product' ='30 year','rate'=6.0 'ProgramID' =>9514), array('product' ='30 year','rate'=6.0 'ProgramID' =>9514), array('product' ='30 year','rate'=6.0 'ProgramID' =>9517), array('product' ='Pay option','rate'=1.0 'ProgramID' =>9513), array('product' ='Pay option','rate'=1.0 'ProgramID' =>9513));
33
3736
by: llothar | last post by:
I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. What is the status about that for the future of python? I know that at the moment allmost nobody in the scripting world has solved this problem, but it bites and it bites hard. Only groovy as a Java Plugin has support but i never tried it. Writing an interpreter that does MT this...
1
2004
by: digidave | last post by:
I am keenly aware that my coding skills are extremely noob but please indulge me a second.. Take a look at these queries.. $sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active = 'yes' ORDER BY year DESC LIMIT 2, 1"; $result = mysql_query($sql); while($fetched = mysql_fetch_array($result)) { $ceiling = $fetched; } $sql = "SELECT * FROM _current_floats WHERE active = 'yes' AND yearID <= $ceiling ORDER BY yearID...
5
3494
by: jimix | last post by:
here's what i have. using microsoft studio #define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> int main( void ) { int year, b, c, e; b = 4; c = 100;
3
4125
by: yogi_bear_79 | last post by:
I have a char *year that contains a 4-digit year (i.e 1929), I use the following syntax c = atoi(year); to convert it to an integer. However I must strip the first two numbers. I've tried to convert it from char* to a string and use the erase function, which works, but then I can't seem to convert the string it to an integer. I am impartial as to when I remove the first two digits, meaning it can be done before or after the conversion...
10
14697
by: sparks | last post by:
We are entering mm/dd/yyyy but some of the date fields only contain years. Can a date be made to only take a year entry if that is all that they have? can it be made to take only 2008 or maybe even 00/00/2008
4
4433
by: hallsers | last post by:
Here is the problem i am having: - When a user logs in, on page load it will take the dob of all users in a stored friends list and compare them against the following conditions - To display any friends with a birthday inside the next 3 days, taking into account leap years for some1 born on the 29th of feb to be born on 28th in non leap years and also to display their age with the reminder. Here is code i have picked up so far. 1. ...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.