probably not the cleanest way to do this, but since nobody else responded, you could try this:
<?
include("config.php");
// Connect To MySQL Server
@mysql_connect($server, $username, $password) or die("Couldn't Connect to Database");
// Select Database
@mysql_select_db($database) or die("Couldn't Select Database");
$query = mysql_query("SELECT DATE_FORMAT(inputedon, '%Y') AS year, DATE_FORMAT(inputedon, '%m') AS month FROM stock ORDER BY year, month") or die(mysql_error());
while($row = mysql_fetch_array($query)) {
$row["month"] = str_replace("01", "January", $row["month"]);
$row["month"] = str_replace("02", "February", $row["month"]);
$row["month"] = str_replace("03", "March", $row["month"]);
$row["month"] = str_replace("04", "April", $row["month"]);
$row["month"] = str_replace("05", "May", $row["month"]);
$row["month"] = str_replace("06", "June", $row["month"]);
$row["month"] = str_replace("07", "July", $row["month"]);
$row["month"] = str_replace("08", "August", $row["month"]);
$row["month"] = str_replace("09", "September", $row["month"]);
$row["month"] = str_replace("10", "October", $row["month"]);
$row["month"] = str_replace("11", "November", $row["month"]);
$row["month"] = str_replace("12", "December", $row["month"]);
if ($row["year"] == '2003') {
$month_array0[] = $row["month"];
}
// previous year
if ($row["year"] == '2002') {
$month_array1[] = $row["month"];
}
}
$month_array0 = array_unique($month_array0);
$month_array1 = array_unique($month_array1);
echo "<b>2003</b><br>";
foreach($month_array0 as $value) {
echo $value . "<br>";
}
echo "<br><b>2002</b><br>";
foreach($month_array1 as $value) {
echo $value . "<br>";
}
?>
Cgraz