Results 1 to 4 of 4
-
8th Sep 2012, 02:46 AM #1OPMember
PHP - Drop down
Hi
I have one date field drop down :
PHP Code:$day = $_POST['day'];
$mon = $_POST['month'];
$year = $_POST['year'];
$dob = $year . "-" . $mon . "-" . $day;
$ins = array(
'd_dob' => $dob
);
PHP Code:<tr>
<td align="left" valign="middle">Date Of Birth<span class="astrikrequired">*</span>: </td>
<td align="left" valign="middle">
<select name="day" id="day" class="tyextfild validate-selection required">
<?php
if($day == '')
{
$day=date(d, strtotime($d_dob));
}
$gnrl->getDropdownList(array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'),$day);
?>
</select>
<select name="month" id="month" class="tyextfild validate-selection required">
<?php
if($month == '')
{
$month=date(m, strtotime($d_dob));
}
?>
<option value="01" <?php if(in_array('01',explode(',',$month))) echo 'selected="selected"';?> >Jan</option>
<option value="02" <?php if(in_array('02',explode(',',$month))) echo 'selected="selected"';?>>Feb</option>
<option value="03" <?php if(in_array('03',explode(',',$month))) echo 'selected="selected"';?>>Mar</option>
<option value="04" <?php if(in_array('04',explode(',',$month))) echo 'selected="selected"';?>>Apr</option>
<option value="05" <?php if(in_array('05',explode(',',$month))) echo 'selected="selected"';?>>May</option>
<option value="06" <?php if(in_array('06',explode(',',$month))) echo 'selected="selected"';?>>Jun</option>
<option value="07" <?php if(in_array('07',explode(',',$month))) echo 'selected="selected"';?>>Jul</option>
<option value="08" <?php if(in_array('08',explode(',',$month))) echo 'selected="selected"';?>>Aug</option>
<option value="09" <?php if(in_array('09',explode(',',$month))) echo 'selected="selected"';?>>Sep</option>
<option value="10" <?php if(in_array('10',explode(',',$month))) echo 'selected="selected"';?>>Oct</option>
<option value="11" <?php if(in_array('11',explode(',',$month))) echo 'selected="selected"';?>>Nov</option>
<option value="12" <?php if(in_array('12',explode(',',$month))) echo 'selected="selected"';?>>Dec</option>
</select>
<select name="year" id="year" class="tyextfild validate-selection required">
<?php
if($year == '')
{
$year=date(Y, strtotime($d_dob));
}
$gnrl->getDropdownList(array('1960','1961','1962','1963','1964','1965','1966','1967','1968','1969','1970','1971','1972','1973','1974','1975','1976','1977','1978','1979','1980','1981','1982','1983','1984','1985','1986','1987','1988','1989','1990','1991','1992','1993','1994','1995','1996','1997','1998','1999','2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012'),$year);
?>
</select>
</td>
</tr>
This works perfectly. After i select date/month/year,and submit, its showing the results stored in the db without any issues... now i need another date set same thing like this. for ex date/month/year drop down. i tried changing the variable names etc but still it shows incorrect date/month/year (previous data) can help me how can i create another set of this 3 dorp down without issues?
ThanksElitePirate Reviewed by ElitePirate on . PHP - Drop down Hi I have one date field drop down : $day = $_POST; $mon = $_POST; $year = $_POST; $dob = $year . "-" . $mon . "-" . $day; $ins = array( Rating: 5
-
9th Sep 2012, 04:53 PM #2Respected Member
I don't understand your code but if you change the id & name of the select staement form day, month, year to 01,02,03 for each like day01 , month01 & year01 & so forth it should do 3 of them..
-
15th Sep 2012, 12:31 AM #3Member
When change
When using different variables you should also use different DB tables.
-
10th Oct 2012, 08:21 AM #4Member
I know your thread is kinda old but I worked this up anyways.
You can try it out here using the following url:
http://inputout.org/sandbox/dropdown.php
the url will accept 'd', 'm', and 'y' as parameters
ex: http://inputout.org/sandbox/dropdown...27&m=04&y=1978
will display 27, April, 1978 in the select boxes
if nothing is passed, it will default to 1, 01, 1960
you would of course, replace the GETs with the values from your database or some POST results
hope this helps.
PHP Code:<html>
<title>Dropdown Selecta</title>
<body>
<?php
$postedDay = isset($_GET['d']) ? (int)$_GET['d'] : 1;
$postedMonth = isset($_GET['m']) ? (int)$_GET['m'] : 01;
$postedYear = isset($_GET['y']) ? (int)$_GET['y'] : 1960;
?>
<select name="day" id="day" class="textfield validate-selection required">
<?php
$days = range(1,31);
foreach ($days as $day) { ?>
<option value="<?php echo $day; ?>"<?php echo $day == $postedDay ? " selected=\"selected\"" : ""; ?>><?php echo $day; ?></option>
<?php } ?>
</select>
<select name="month" id="month" class="textfield validate-selection required">
<?php
$months = array('01'=>'Jan', '02'=>'Feb', '03'=>'Mar', '04'=>'Apr', '05'=>'May', '06'=>'Jun', '07'=>'Jul', '08'=>'Aug', '09'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');
foreach ($months as $key=>$value) { ?>
<option value="<?php echo $key; ?>"<?php echo $key == $postedMonth ? " selected=\"selected\"" : ""; ?>><?php echo $value; ?></option>
<?php } ?>
</select>
<select name="year" id="year" class="textfield validate-selection required">
<?php
$years = range('1960', '2012');
foreach ($years as $year) {?>
<option value="<?php echo $year; ?>"<?php echo $year == $postedYear ? " selected =\"selected\"" : ""; ?>><?php echo $year; ?></option>
<?php } ?>
</select>
</body>
</html>
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Rankings Drop
By GBot in forum Whitehat SEOReplies: 0Last Post: 14th Dec 2013, 08:41 PM -
HTC One X Drop Test Must See
By sahil00150 in forum General DiscussionReplies: 2Last Post: 23rd Apr 2012, 01:41 AM -
Anyone done Drop shipping?
By tinhead in forum Webmasters, Money MakingReplies: 7Last Post: 31st Jan 2012, 01:42 PM -
need help in drop down menu
By nfury007 in forum IP.BoardReplies: 3Last Post: 12th Jun 2011, 07:49 AM -
how to drop 1 packet ?
By Keosoft90 in forum Technical and Security TutorialsReplies: 2Last Post: 10th Apr 2011, 12:11 PM
themaManager - edit and manage...
Version 4.18 released. Open older version (or...