データベースからいくつかの日付を選択し、これらの日付を月ごとに表示しました。次のコードを使用しています
$work_res = mysql_query("(SELECT DISTINCT date FROM `work_details` WHERE employee_id='" . $emp_id . "' and date between '" . $qsdate . "' and '" . $qedate . "') UNION (SELECT holy_date from holiday where holy_date between '" . $qsdate . "' and '" . $qedate . "')");
while ($row = mysql_fetch_array($work_res)) {
echo date("F", $test_date).'<br>';
while ((date("Y-m-d", $test_date) < $row['date']) && ($flag = 0)) {
if (!(date('N', strtotime(date("Y-m-d", $test_date))) >= 6)) {
echo "<tr ><td align=center class=fontclass style=color:FF0000>" . date("Y-m-d F", $test_date) . "</td></tr>";
}
$test_date = $test_date + ($day_incrementer * 60 * 60 * 24);
}
$flag = 1;
while ((date("Y-m-d", $test_date) != $row['date'])) {
if (!(date('N', strtotime(date("Y-m-d", $test_date))) >= 6)) {
echo "<tr><td align=center class=fontclass style=color:FF0000>" . date("Y-m-d F", $test_date) . "</td></tr>";
}
$test_date = $test_date + ($day_incrementer * 60 * 60 * 24);
}
$test_date = $test_date + ($day_incrementer * 60 * 60 * 24);
}
while (date("Y-m-d", $test_date) <= date("Y-m-d", $end_date)) {
if (!(date('N', strtotime(date("Y-m-d", $test_date))) >= 6)) {
echo "<tr><td align=center class=fontclass style=color:FF0000>" . date("Y-m-d F", $test_date) . "</td></tr>";
}
$test_date = $test_date + ($day_incrementer * 60 * 60 * 24);
}
return;
}
次のような結果が得られました
2012-01-16 January
2012-01-26 January
2012-01-27 January
2012-02-02 February
2012-03-21 March
2012-03-22 March
これらの日付を次のように表示したい
January (3)
2012-01-16
2012-01-26
2012-01-27
February (1)
2012-02-02
March(2)
2012-03-21
2012-03-22
これは可能ですか?助けてください