Hello all,
I have put together a script that populates a dropdown menu from a database. My database contains a table called casinocredit, and it contains records that have been enterend over 2 different months (may and june). There is a field in the database that contains the date in this format: 2006-05-12 00:00:00
So The drop down is currently showing a month for each of those records. I was hoping that it would only display one. (the plan is when a user selects a month (say May) and hits submit, then I would display all of Mays records on a different page) See the image i have attached for a view of what is happening.
Anyone have any ideas about how I could fix this? (I am not expecting anyone to do this for me, I 'm just looking to be put in the right direction 🙂 )
Heres my code so far...
<?
...
db stuff
...
// select the ddate
$query = mysql_query("SELECT DISTINCT (ddate), ID FROM casinocredit");
// start to process my form
echo "<form action=\"cats.php\" method=\"POST\"><select name=\"clients\"><option value=\"\" \"selected\">Select A Client</option>";
//loop through my records
while ($row = mysql_fetch_array($query))
{
// this part changes how the date is displayed
$formattedDate = date("F Y", strtotime($row['ddate']));
echo "<option value=\"{$row['ID']}\">{$formattedDate}</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\"Go\"></form>";
?>
Any advice is appreciated.
Thanks