brown2005 Posted August 11, 2006 Share Posted August 11, 2006 i need to populate a select box with the days of the week, starting from today and finishing with the day before today, i.e.friday. sat. sun. mon. tue. wed. thursday. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 11, 2006 Share Posted August 11, 2006 Try[code]<?php$today = mktime(0,0,0);echo '<select name="day">';for ($i=0; $i<7; $i++) { $val = date('l', strtotime("+$i days", $today)); echo "<option value='$val'>$val</option>";}echo '</select>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted August 11, 2006 Share Posted August 11, 2006 My version ;)[code]<?php$now=time();$day_seconds=60*60*24;echo('<select name="day">');$count=0;while($count<=6){$timestamp=$now+($count*$day_seconds);$day=date("l",$timestamp);echo('<option name="'.$day.'">'.$day);$count++;}echo '</select>';?>[/code]I tested it and it works :)Orio. Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 15, 2006 Author Share Posted August 15, 2006 thanks both of u... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.