You'll need to check whether month is set and if so use the month & year query and if not just query on the year.
I don't think it's reasonably doable in a single statement.
i.e.
if ($month != "") {
$sql="SELECT * FROM weight WHERE month='$month' & year='$year';
} else {
$sql="SELECT * FROM weight WHERE year='$year'";
}
(although someone may well have a cleverer solution) |