fsoftball 0 Report post Posted July 12, 2005 Hi,I have a page where the user enters a date. I would like to use drop down boxes for the date. I would like the current date to be the default date. I think that part is pretty easy. However, I am having trouble listing all of the months. It wills tart at July and end at December. I need to list January through June. Anyone know a good way to list all the months? I am assuming that I will be able to do the same sort of thing for the date.Thanks! Share this post Link to post Share on other sites
palladin 0 Report post Posted July 12, 2005 Look at this <?// Months Start Here$month[0]="--";$month[1]="January";$month[2]="February";$month[3]="March";$month[4]="April";$month[5]="May";$month[6]="June";$month[7]="July";$month[8]="August";$month[9]="September";$month[10]="Octobre";$month[11]="November";$month[12]="December";// End Months Start Here// Days Start Here$days[0]="Sun";$days[1]="Mon";$days[2]="Tues";$days[3]="Wed";$days[4]="Thu";$days[5]="Fri";$days[6]="Sat";// End Days Start Here//Add Month Func.$dayno=(int)date("w");// End Add Month Func.//Add Month Func.$monno=(int)date("m");// End Add Month Func.// Show date on the page.echo $days[$dayno]." ".$month[$monno]." ".date("d")."/".date("Y");// End Show date on the page.?> --------------------Practice is when evrything is work but no one know why.Theory is when work nothing but evry one know why.Programmers join Practice with Theory - nothing work and no one know why Share this post Link to post Share on other sites
fsoftball 0 Report post Posted July 14, 2005 Thanks palladin. While that is helpful, it isn't really what I'm looking.Here is a snip of the code I currently use:echo "<SELECT name='month'>\n";echo "<option value ='Apr'>April</option>\n";echo "<option value ='May'>May</option>\n";echo "<option value ='June'>June</option>\n";echo "<option value ='July'>July</option>\n";echo "<option value ='August'>August</option>\n";echo "</select>\n";echo " \n";I want 'June' to be the top month displayed, but I do not want to loose 'Apr' and 'May'. This might be an html question rather than a PHP question. Share this post Link to post Share on other sites
sachavdk 0 Report post Posted July 15, 2005 Maybe this is what you want: <html><body><select name="datum"><?$date = getdate();for ($i=$date[0];$i<=($date[0]+31536000);$i+=86400){ echo "<option value=\"".date("Y/d/m H:i:s",$i)."\">".date("Y/d/m H:i:s",$i)."</option>";}?></select></body></html> the list orders the dates from the day the list is called (ie when you're testing the script) until today next year. if you don't want today next year to be listed use in the code instead of 31536000 this number: 31449600.The date is written in the format YYYY/DD/MM HH:MM:SS (year/day/month hour:minute:second). You can change it if you want. If you want to use other look here http://be.php.net/manual/en/function.date.php.You only have to change the formatting "Y/d/m H:i:s" to ie "d/m/Y" but remember with this script you have to do it twice. Once for the value and once for the one that is written in de dropdownlist.If anything doesn't work like you want please ask Share this post Link to post Share on other sites
palladin 0 Report post Posted July 15, 2005 Hmm you mean wanna select June as default ? echo "<SELECT name='month'>\n";echo "<option value ='Apr'>April</option>\n";echo "<option value ='May'>May</option>\n";echo "<option [B]selected[/B] value ='June'>June</option>\n";echo "<option value ='July'>July</option>\n";echo "<option value ='August'>August</option>\n";echo "</select>\n";echo " \n"; Use selected after otpion and combo box will set a June as default without touching them. --------------------Practice is when evrything is work but no one know why.Theory is when work nothing but evry one know why.Programmers join Practice with Theory - nothing work and no one know why Share this post Link to post Share on other sites
fsoftball 0 Report post Posted July 15, 2005 That is what I'm looking for palladin. But I can' seem to get it to to work. do I need eto do somethingmore thatn simply add the selected to that option? When I do it, shouldn't that month be displayed in the drop down menu? Thanks again. Share this post Link to post Share on other sites