I am trying to populate a drop down menu with a mysql database. I was hoping to have a selection of months in the dropdown menu, based on date fields in my database (displayed like january, february, march, april, ,may etc)
when a user then selects a month, they will be brought to a new page that will have only the records created in that month.
But in my database, the date is stored in this format: 2006-05-12 00:00:00
Is there any way that I could replace the dates with the months?
for example : 2006 - 05, would be May 2006.
if you need to see my code, here it is:
PHP Code:
<?
//database connection
$query = mysql_query("SELECT * FROM casinocredit");
// start to print out the form
echo "<form action=\"cats.php\" method=\"POST\"><select name=\"clients\"><option value=\"\" \"selected\">Select A Client</option>";
you need to use the following function
date('M-Y'),strtotime($row['ddate']))
this function will display the date in the wanted format
reply for more information
Bookmarks