私は、教師が生徒を管理するための簡単な不在スクリプトを作成し始めています。
同じ生徒のリストを 5 つのテーブルに入力する必要があります。現在の週 (月曜日から金曜日) の各日に対して 1 つのテーブル。
現時点では次のコードがあります
学生のリスト SQL クエリ:
SELECT s.student_id, s.student_firstname, s.student_lastname,
a.student_absence_startdate, a.student_absence_enddate, a.student_absence_type
FROM students s
LEFT JOIN studentabsence a ON a.student_id = s.student_id
WHERE a.student_absence_startdate
IS NULL OR
'2012-06-20'
BETWEEN
a.student_absence_startdate AND a.student_absence_enddate
このクエリは、すべての学生を選択し、学生の欠席情報を保持するリンク テーブルである別のテーブルを結合します。
次のようにコードを 5 回入力します。
<?php
$data = array();
while ($row = mysql_fetch_array($list_students)) {
$data[] = $row;
}
?>
<table>
<?php
foreach($data as $row){
$class = "";
if ($row['student_absence_type'] == 2) {$class = " style='background:#f00;'";}
else if ($row['student_absence_type'] == 3) {$class = " style='background:#8A2BE2;'";}
echo "<tr><td$class>";
echo "<a class='ajaxlink' href='#' rel='pages/ajaxAbsence.php?student_id=".$row['student_id']."'>".$row['student_firstname']." ".$row['student_lastname']."</a>";
echo "</td></tr>\n";
}
?>
</table> <!-- Repeat -->
私の質問は、日付関数をどのように管理する必要があるかです。
SQL クエリでわかるように、日付をハードコーディングしました。学生がリストされているテーブルの日付を自動的に選択する必要があります。
例えば:
table > Monday (2012-07-23)
the user John Doe has absence information in this span, based on the above query. Let's change the background of <td>
table > Tuesday (2012-07-24)
the user John Doe has no absence information in this span. Just list him.
etc...
あなたが私のコードを書くことを期待していません。どのように考えているのか興味があります。私はプログラミングにかなり慣れていません。