tauchai83 Posted March 3, 2007 Share Posted March 3, 2007 <?php $day=date("d"); $month=date("m"); $year=date("Y"); $today=date("Y-m-d").":".date("Y-m-d"); $yesterday=date("Y-m-d",mktime(0,0,0,$month,$day-1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day-1,$year)); $week=date("Y-m-d",mktime(0,0,0,$month,$day-6,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $thismonth=date("Y-m-d",mktime(0,0,0,$month,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $lastmonth=date("Y-m-d",mktime(0,0,0,$month-1,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month-1,date("t",mktime(0,0,0,$month-1,1 ,$year)),$year)); $thisyear=date("Y-m-d",mktime(0,0,0,1,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $alltime=date("Y-m-d",mktime(0,0,0,1,1,0000)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$today)); $option_values=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles=array("Today","Yesterday","Last 7 Days","This Month","Last Month","This Year","All Time"); echo " <tr> <td><b>Date Range:</b> <select name='date_range'>"; if($option_values[0]=!'') { echo"<option selected value=\"$option_values[0]\">$option_titles[0]</option>"; } for($k=1;$k< count($option_values); $k++) { if($option_values[$k]!=$option_values[0] ) { echo " <option value='$option_values[$k]'>$option_titles[$k]</option>"; } } echo '</select> </td> </tr>'."\n"; ?> The above is the select code that only pass the option value "1" to the next processing page. I trying to select a date range as you can see on the code. After i use mktime function, the select option only have one. What is the problem with my code here? For the next processing page, the code look like this: if(isset($Submit)) { $date_range=$_POST['date_range']; $dates=explode(':',$date_range); $date1=$dates[0]; $date2=$dates[1]; } I only get the value "1" from the date range POST varibale. If i select option number 2 and so fouth, the nth appear. $date1 and $date2 not working. Can anyone help me? thanks in advanced. Link to comment https://forums.phpfreaks.com/topic/40947-php-select/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.