I was wondering if anyone can help me sort this problem!

I basically have a member profile feature on my site that has an update page! Members can update information such as their date of birth, location etc!

I currently have a text box in which members have to add their date of birth in numerical format .... This confuses alot of members due to the difference format of USA/UK. i.e. DD/MM/YYYY for UK and MM/DD/YYYY!

I would like to have it so that instead of the member typing in the Date/Month and Year ... there is a drop down menu.

I have worked out how to do this and it successfully updates the MySQL table.

However .... when I have updated my date of birth and then return to the edit profile page ... the drop down boxes of the date of birth show the first options in the menu.

So for example ... my date of birth is march 12th 1983!

I update this in the update page and then on return the drop down box shows Jan 1st 1933 which is the first selection of each drop down.

I have tried to use the VALUE="$explodeBday[2]" code but not sure if I have done is right! :S

Here is the code snippet on the profile edit page:

<select name="update_mybirthmonth" VALUE="$explodeBday[0]">
        <option value='1'>Jan
<option value='2'>Feb
<option value='3'>Mar
<option value='4'>Apr
<option value='5'>May
<option value='6'>Jun
<option value='7'>Jul
<option value='8'>Aug
<option value='9'>Sep
<option value='10'>Oct
<option value='11'>Nov
<option value='12'>Dec
      </select> <select name="update_mybirthday" VALUE="$explodeBday[1]">
        <option value='1'>1
<option value='2'>2
<option value='3'>3
<option value='4'>4
<option value='5'>5
<option value='6'>6
<option value='7'>7
<option value='8'>8
<option value='9'>9
<option value='10'>10
<option value='11'>11
<option value='12'>12
<option value='13'>13
<option value='14'>14
<option value='15'>15
<option value='16'>16
<option value='17'>17
<option value='18'>18
<option value='19'>19
<option value='20'>20
<option value='21'>21
<option value='22'>22
<option value='23'>23
<option value='24'>24
<option value='25'>25
<option value='26'>26
<option value='27'>27
<option value='28'>28
<option value='29'>29
<option value='30'>30
<option value='31'>31
      </select> <select name="update_mybirthyear" VALUE="$explodeBday[2]">
        <option value='1933'>1933
<option value='1934'>1934
<option value='1935'>1935
<option value='1936'>1936
<option value='1937'>1937
<option value='1938'>1938
<option value='1939'>1939
<option value='1940'>1940
<option value='1941'>1941
<option value='1942'>1942
<option value='1943'>1943
<option value='1944'>1944
<option value='1945'>1945
<option value='1946'>1946
<option value='1947'>1947
<option value='1948'>1948
<option value='1949'>1949
<option value='1950'>1950
<option value='1951'>1951
<option value='1952'>1952
<option value='1953'>1953
<option value='1954'>1954
<option value='1955'>1955
<option value='1956'>1956
<option value='1957'>1957
<option value='1958'>1958
<option value='1959'>1959
<option value='1960'>1960
<option value='1961'>1961
<option value='1962'>1962
<option value='1963'>1963
<option value='1964'>1964
<option value='1965'>1965
<option value='1966'>1966
<option value='1967'>1967
<option value='1968'>1968
<option value='1969'>1969
<option value='1970'>1970
<option value='1971'>1971
<option value='1972'>1972
<option value='1973'>1973
<option value='1974'>1974
<option value='1975'>1975
<option value='1976'>1976
<option value='1977'>1977
<option value='1978'>1978
<option value='1979'>1979
<option value='1980'>1980
<option value='1981'>1981
<option value='1982'>1982
<option value='1983'>1983
<option value='1984'>1984
<option value='1985'>1985
<option value='1986'>1986
<option value='1987'>1987
<option value='1988'>1988
<option value='1989'>1989
<option value='1990'>1990
<option value='1991'>1991
<option value='1992'>1992
<option value='1993'>1993
<option value='1994'>1994
<option value='1995'>1995
<option value='1996'>1996
<option value='1997'>1997
<option value='1998'>1998
<option value='1999'>1999
<option value='2000'>2000
<option value='2001'>2001
<option value='2002'>2002
<option value='2003'>2003
<option value='2004'>2004
<option value='2005'>2005
<option value='2006'>2006
<option value='2007'>2007
<option value='2008'>2008

This is the code that is within the .pro.php that actually makes the updates!

if (($update_mybirthmonth >= 1) AND ($update_mybirthmonth <= 12) AND ($update_mybirthday >= 1) AND ($update_mybirthday <= 31) AND ($update_mybirthyear >= 0) AND ($update_mybirthyear <= $this_year))


        $birthday = "$update_mybirthmonth-$update_mybirthday-$update_mybirthyear";

        mysql_query("UPDATE members_profiles2 SET birthday = '$birthday' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error());


This is the database table export:

CREATE TABLE IF NOT EXISTS `members_profiles2` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
  `real_name` varchar(64) NOT NULL default '',
  `email` varchar(64) NOT NULL default '',
  `birthday` varchar(12) NOT NULL default '',
  `date_registered` int(11) NOT NULL default '0',
  `profile` text NOT NULL,
  `gender` tinyint(4) NOT NULL default '0',
  `referrals` int(11) NOT NULL default '0',
  `referrals2` int(11) NOT NULL default '0',
  `mail_settings` tinyint(4) NOT NULL default '0',
  `signature` varchar(126) NOT NULL default '',
  `game` int(11) NOT NULL default '1',
  `location` text NOT NULL,
  `avatar_selected` varchar(255) NOT NULL default 'blank.gif',
  `avatar_find` varchar(255) NOT NULL default '',
  `interests` text NOT NULL,
  `hobbies` text NOT NULL,
  `my_info` text NOT NULL,
  `my_update` varchar(102) NOT NULL default '',
  PRIMARY KEY  (`id`)

I would appreciate any help!


8 Years
Discussion Span
Last Post by enim213

I believe it's a problem in your HTML -- the select tag doesn't support "value". You have to set the <option> you wish to default to by using "SELECTED". For instance:

<select name="myselect">
  <option value="1">First choice</option>
  <option value="2">Second choice</option>
  <option value="3" SELECTED>Third choice</option>

You'll need to procedurally compare values to find out which item to default as "SELECTED".




Thanks for your reply. I did actually have the SELECTED option in but took it out as obviously this wasnt much different and still showed the wrond birthdate from the database.

May I ask how I would compare these values as I have no idea ?



You will need to compare the value of the select option to your $_POST or $_GET values. e.g.:

if( $_POST['update_mybirthyear'] == '1983' ) echo " SELECTED";

i think you are using like this

$birthday = "$update_mybirthmonth-$update_mybirthday-$update_mybirthyear";

it will change that format

$birthday = $update_mybirthmonth."/".$update_mybirthday."/".$update_mybirthyear;

i think it will be done.


you can use this code for your dropdown...

<?php					//month
					$month_names = array("January","February","March","April","May","June","July","August","September","October","November","December");
					$month .= "<select name='month[]'>";
								$v = $x+1;
										$month .="<option value='$v' selected='selected'>$month_names[$x]</option>";
										$month .="<option value='$v'>$month_names[$x]</option>";
					$month .="</select>";
					$day .= "<select name='day[]'>";
										$day .= "<option value='$z' selected='selected'>$z</option>";
										$day .= "<option value='$z'>$z</option>";	
					$day .= "</select>";
					$year .= "<select name='year[]'>";
										$year .= "<option value='$y'>$y</option>";
										$year .= "<option value='$y'>$y</option>";	
					$year .= "</select>";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.