I have been trying to create a way for a user to select data from a MySQL database depending on the date range they select from drop down lists. The user has to select the start day, month and year and the end day, month and year. The data between these dates is then displayed within a html table. This also means there is 6 drop down menus in total. The code so fare is as follows -
table.altrowstable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 1px; border-color: #a9c6c9; border-collapse: collapse; text-align: center; } table.altrowstable th { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } table.altrowstable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } .oddrowcolor{ background-color:#d4e3e5; } .evenrowcolor{ background-color:#c3dde0; }
<?php
$username="root";
$password="";
$database="btg";
$date1 ="";
$date2 ="";
if (isset($_POST['Submit']))
{
$date1 = date('Y-m-d', strtotime(mktime(0,0,0,$_POST['startday'],$_POST['startmonth'],$_POST['startyear'])));
$date2 = date('Y-m-d', strtotime(mktime(0,0,0,$_POST['endday'],$_POST['endmonth'],$_POST['endyear'])));
}
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM users
WHERE corrispondance BETWEEN '$date1' AND '$date2'");
$num=mysql_numrows($result);
?>
|
any help would be awsome as i cant seem to get this to work
Cheers