Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

array

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.