April 1, 200917 yr Hey, I'm creating a website for a website that will allow people to book accomodation. I need to generate a SELECT list which contains a list of saturdays (with the dd/mm/yyyy) for the next two years. I'm able to use either JavaScript or PHP to generate this list. I've had several attempts of coding something myself, but am not getting very far at all. Anyone got any suggestions on how I can do this? Or a link to a script that will do this? Thanks in advance!
April 1, 200917 yr You could use something along the lines of this in php: <?php $start = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $end = mktime(0, 0, 0, date("m"), date("d"), date("Y")+2); echo '<select name="saturdays">'; while ($start <= $end) { if (date('l', $start) == 'Saturday') { $day = date('l d/m/Y', $start); $value = date('d/m/Y', $start); echo "<option value=\"$value\">$day</option>\n"; } $start += 86400; } echo "</select>"; ?>
Create an account or sign in to comment