redarrow Posted October 15, 2006 Share Posted October 15, 2006 can you see why the $day select is outputting the range as a whole and not as the select box as intrnded palease help cheers.[code]<?phpif($_POST['submit']){foreach($dates as $x){echo $x;} }echo "<form method='POST' action='' ";$day=range(1,31);echo"<select name='dates[]'>";foreach($day as $d){echo"<option value='$d'>$d</option>";}echo"</select>";$month=range(1,12);echo"<select name='dates[]'>";foreach($month as $n){echo"<option value='$n'>$n</option>";}echo"</select>";$year=range(2006,2020);echo"<select name='dates[]'>";foreach($year as $y){echo"<option value='$y'>$y</option>";}echo"</select><br><br>";echo "<input type='submit' name='submit' value='send'>";echo "</form>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/23978-select-problam-with-range/ Share on other sites More sharing options...
marcus Posted October 15, 2006 Share Posted October 15, 2006 echo "<form method='POST' action='' ";should you end that? action=''> Link to comment https://forums.phpfreaks.com/topic/23978-select-problam-with-range/#findComment-108941 Share on other sites More sharing options...
redarrow Posted October 15, 2006 Author Share Posted October 15, 2006 I came up with this as a date select box.what do you think is it acceptable.[code]<?phpif($_POST['submit']){$x=implode("-",$dates);$result=mktime($x);// timestamp for the databaseecho date("d-m-y",$result); // format timestamp any order} echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'> ";$day=range(1,31);echo"<select name='dates[]'>";foreach($day as $d){echo"<option value='$d'>$d</option>";}echo"</select>";$month=range(1,12);echo"<select name='dates[]'>";foreach($month as $n){echo"<option value='$n'>$n</option>";}echo"</select>";$year=range(2006,2020);echo"<select name='dates[]'>";foreach($year as $y){echo"<option value='$y'>$y</option>";}echo"</select><br><br>";echo "<input type='submit' name='submit' value='send'>";echo "</form>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/23978-select-problam-with-range/#findComment-108946 Share on other sites More sharing options...
redarrow Posted October 15, 2006 Author Share Posted October 15, 2006 There we go a full working select box for dates.[code]<?phpif($_POST['submit']){$result1=date("d-m-Y", mktime(0, 0, 0, $dates[1], $dates[0], $dates[2]));echo " This is the date you selected $result1";$result2=strtotime($result1);echo "<br>This is the timestamp for the date you selected $result2";} echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'> ";$day=range(1,31);echo"<select name='dates[]'>";foreach($day as $d){echo"<option value='$d'>$d</option>";}echo"</select>";$month=range(1,12);echo"<select name='dates[]'>";foreach($month as $n){echo"<option value='$n'>$n</option>";}echo"</select>";$year=range(2006,2020);echo"<select name='dates[]'>";foreach($year as $y){echo"<option value='$y'>$y</option>";}echo"</select><br><br>";echo "<input type='submit' name='submit' value='send'>";echo "</form>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/23978-select-problam-with-range/#findComment-108953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.