Dzięki bartek124. Naprawiłem błąd i śmiga :)
Ale w kolejnym kodzie też jakiś błąd... :/
// (...)
if (isset($_POST['save'])) {
$class = stripinput($_GET['class']);
$subject_name = stripinput($_POST['subject_name']);
$teacher = isnum($_POST['teacher']) ? $_POST['teacher'] : "";
if ($subject_name != "" && $teacher != "") {
// Tworzenie tabeli z przedmiotem dla wybranej klasy
$result = dbquery("DROP TABLE IF EXISTS ".DB_PREFIX.$subject_name."_".$class);
$result = dbquery("CREATE TABLE ".DB_PREFIX.$subject_name."_".$class." (
".$subject_name."_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
d_num INT(3) NOT NULL DEFAULT '',
o1 VARCHAR(2) NOT NULL DEFAULT '',
o2 VARCHAR(2) NOT NULL DEFAULT '',
o3 VARCHAR(2) NOT NULL DEFAULT '',
o4 VARCHAR(2) NOT NULL DEFAULT '',
o5 VARCHAR(2) NOT NULL DEFAULT '',
o6 VARCHAR(2) NOT NULL DEFAULT '',
o7 VARCHAR(2) NOT NULL DEFAULT '',
o8 VARCHAR(2) NOT NULL DEFAULT '',
o9 VARCHAR(2) NOT NULL DEFAULT '',
o10 VARCHAR(2) NOT NULL DEFAULT '',
o11 VARCHAR(2) NOT NULL DEFAULT '',
o12 VARCHAR(2) NOT NULL DEFAULT '',
o13 VARCHAR(2) NOT NULL DEFAULT '',
o14 VARCHAR(2) NOT NULL DEFAULT '',
o15 VARCHAR(2) NOT NULL DEFAULT '',
PRIMARY KEY (".$subject_name."_id)
) TYPE=MyISAM;");
if (!$result) { $fail = true; }
$old_teacher = dbarray(dbquery("SELECT * FROM ".DB_USERS." WHERE user_id='".$teacher."'"));
$result = dbquery("UPDATE ".DB_USERS." SET teacher_subject='".$old_teacher['teacher_subject'].($old_teacher['teacher_subject'] != "" ? "." : "").$class.":".$subject_name."' WHERE user_id='".$teacher."'");
if ($fail) { redirect(FUSION_SELF.$aidlink."&class=".$class."&status=su"); } else { redirect(FUSION_SELF.$aidlink."&class=".$class."&status=sn"); }
}
redirect(FUSION_SELF.$aidlink."&class=".$class."&status=su");
}
// (...)
else {
opentable($locale['401']);
// lista przedmiotów (wywalić przedmioty które klasa już ma...)
$lsubjects = dbquery("SELECT * FROM ".DB_SUBJECTS." ORDER BY subject_name");
$lteachers = dbquery("SELECT * FROM ".DB_USERS." WHERE user_level>='104' ORDER BY surname DESC, name DESC");
if (dbrows($lsubjects) != 0 && dbrows($lteachers) != 0) {
$subjectslist = "";
while ($data1 = dbarray($lsubjects)) {
$subjectslist .= "<option value='".$data1['subject_name']."'>".$data1['subject_name']."</option>\n";
}
$teacherslist = "";
while ($data2 = dbarray($lteachers)) {
$teacherslist .= "<option value='".$data2['user_id']."'>".$data2['name']." ".$data2['surname']."</option>\n";
}
} else {
echo "<div align='center'>".$locale['404']."</div>";
}
echo "<form name='inputform' method='post' action='".FUSION_SELF.$aidlink."&class=".$_GET['class']."' onsubmit='return ValidateForm(this);'>\n";
echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['422']."</td>\n";
echo "<td width='80%' class='tbl'><select name='subject_name' class='textbox'>\n";
echo "<option value='0'>".$locale['424']."</option>\n".$subjectslist."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['423']."</td>\n";
echo "<td width='80%' class='tbl'><select name='teacher' class='textbox'>\n";
echo "<option value='0'>".$locale['424']."</option>\n".$teacherslist."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
echo "<input type='submit' name='save' value='".$locale['437']."' class='button' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
closetable();
echo "<script type='text/javascript'>\n"."function DeleteClassSubjects() {\n";
echo "return confirm('".$locale['451']."');\n}\n";
echo "function ValidateForm(frm) {\n"."if(frm.subject_name.value=='') {\n";
echo "alert('".$locale['450']."');\n"."return false;\n}\n}\n";
}
Kliknij i zaczekaj na załadowanie kodu ... |