示例#1
0
function exam_subjects($exam_id)
{
    $exam_subjects = array();
    $sql = "select SubjectIDs from exams where ExamId='{$exam_id}' ORDER BY SubjectIDs DESC";
    // $sql ="select exams.SubjectIDs as SubjectIDs from exams,subjects where exams.ExamId='$exam_id' and exams.SubjectIDs=subjects.SubjectId and subjects.has_partition!=1";
    $res = mysql_query($sql);
    $row = mysql_fetch_array($res);
    $subject_ids = explode(',', $row['SubjectIDs']);
    foreach ($subject_ids as $subject_id) {
        $sql = "select SubjectId from subjects where has_partition!=1 and SubjectId='{$subject_id}'";
        $res = mysql_query($sql);
        $row = mysql_fetch_array($res);
        $subject_idss = $row['SubjectId'];
        if ($subject_idss != NUll) {
            $exam_subjects[$subject_id] = get_subject_name($subject_id);
        }
    }
    return $exam_subjects;
}
include "getQuestion.php";
//echo(getQuestion(1,1) );
?>
 
 <?php 
$subject = $_POST["subject"];
$num = $_POST["num"];
if ($subject != "" && $num != "") {
    echo "<b>Ban dang lam bai tap mon " . $subject . "</b><br />";
    $subject_id = get_subject_ID($subject);
    echo getQuestion($subject_id[1], $num);
} else {
    echo "<form action=\"testmysql.php\" method=\"post\">";
    echo "Ma môn hoc :<select name=\"subject\">";
    echo "<option></option>";
    $all_subject = get_subject_name();
    $i = 1;
    while ($all_subject[$i] != "") {
        echo "<option>" . $all_subject[$i] . "</option>";
        $i++;
    }
    echo "\t\t</select>";
    echo "So luong cau hoi :<select name=\"num\">";
    echo "<option></option>";
    echo "<option>1</option>";
    echo "<option>5</option>";
    echo "<option>10</option>";
    echo "<option>15</option>";
    echo "\t\t</select>";
    echo "<input type=\"submit\" value=\"Lam  bai\"/>";
    echo "</form>";