-
Notifications
You must be signed in to change notification settings - Fork 0
/
editQuestion.php
169 lines (167 loc) · 7.37 KB
/
editQuestion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src = "main.js"></script>
<title>Edit Question</title>
</head>
<body>
<div class = "mainDiv" align = "center">
<?php
include_once("header.php");
$question_id1 = $_GET["question_id"];
$q3 = mysql_query("select q.marks as marks, q.status as status, s.subject_id as subject_id, s.subject_name as subject_name, st.subtopic_id as subtopic_id, st.subtopic_name as subtopic_name, q.question_id as question_id, q.question as question from subtopics as st, subjects as s, questions as q where q.question_id = '$question_id1' and st.subject_id = s.subject_id and st.subtopic_id = q.subtopic_id order by q.question, st.subtopic_name, s.subject_name asc;");
if(mysql_num_rows($q3)>0)
{
$r3 = mysql_fetch_array($q3);
$question1= $r3["question"];
$subtopic_id1= $r3["subtopic_id"];
$subject_name1= $r3["subject_name"];
$subject_id1= $r3["subject_id"];
$marks1= $r3["marks"];
$status1= $r3["status"];
}
?>
<form action = "editquestion2.php" method = "POST" onSubmit = "return val_addquestion();">
<table cellspacing = "1px" cellpadding = "5px" border = "1px" width = "100%" class = "mainTable" align = "center">
<tr>
<td width = "50%">
Question Name:
</td>
<td>
<textarea name = "question" id = "question" rows="4" cols = "30"><?php echo ($question1);?></textarea>
</td>
</tr>
<tr>
<td width = "50%">
Subject Name:
</td>
<td>
<select name = "subject_id" id = "subject_id" onChange = "getSubTopics()">
<option value = "-1">Select Subject</option>
<?php
$q3 = mysql_query("select * from subjects order by subject_name asc;");
if(mysql_num_rows($q3)>0)
{
while($r3 = mysql_fetch_array($q3))
{
$subject_id = $r3["subject_id"];
$subject_name = $r3["subject_name"];
if($subject_id == $subject_id1)
{
?>
<option selected value = "<?php echo($subject_id);?>"><?php echo($subject_name);?></option>
<?php
}
else{
?>
<option value = "<?php echo($subject_id);?>"><?php echo($subject_name);?></option>
<?php
}
}
}
?>
</select>
</td>
</tr>
<tr>
<td width = "50%">
Question:
</td>
<td id = "subtopic_td">
<select name = "subtopic_id" id = "subtopic_id" style = "width:270px;">
<?php
$q3 = mysql_query("select * from subtopics where subject_id = '$subject_id1';");
if(mysql_num_rows($q3)>0)
{
while($r3 = mysql_fetch_array($q3))
{
$subtopic_id = $r3["subtopic_id"];
$subtopic_name = $r3["subtopic_name"];
if($subtopic_id == $subtopic_id1)
{
?>
<option selected value = "<?php echo($subtopic_id);?>"><?php echo($subtopic_name);?></option>
<?php
}
else
{
?>
<option value = "<?php echo($subtopic_id);?>"><?php echo($subtopic_name);?></option>
<?php
}
}
}
?>
</select>
</td>
</tr>
<tr>
<td width = "50%">
Marks:
</td>
<td>
<select name = "marks" id = "marks">
<option value = "-1">Select Marks</option>
<?php
$k=5;
while($k<=15)
{
if($k == $marks1)
{
?>
<option selected value = "<?php echo ($k);?>"><?php echo ($k);?></option>
<?php
}
else
{
?>
<option value = "<?php echo ($k);?>"><?php echo ($k);?></option>
<?php
}
$k=$k+5;
}
?>
</select>
</td>
</tr>
<tr>
<td width = "50%">
Status:
</td>
<td>
<select name = "status" id = "status">
<?php
if($status1=="1")
{
?>
<option selected value = "1">Active</option>
<option value = "0">InActive</option>
<?php
}
else
{
?>
<option value = "1">Active</option>
<option selected value = "0">InActive</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td colspan = "2" align = "center">
<input type = "hidden" value = "<?php echo ($question_id1);?>" name = "question_id" id = "question_id">
<input type = "submit" value = "Update">
</td>
</tr>
</table>
</form>
<div>
<?php
include_once("listQuestion.php");
?>
</div>
</div>
</body>
</html>