001.
<? session_start() ?>
002.
<?
require_once
(
'Connections/dbname.php'
);
003.
if
(!isset(
$_SESSION
)){
004.
}
005.
$topic
=
$_GET
[
'topic'
];
006.
$ques_id
=
$_GET
[
'ques_id'
];
007.
$type_id
=
$_GET
[
'type_id'
];
008.
009.
?>
010.
011.
<div align=
"center"
>
012.
<table width=
"570"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
>
013.
<tr>
014.
<td height=
"31"
align=
"left"
valign=
"middle"
bgcolor=
"#000033"
>
015.
<span
class
=
"style8"
>></span><span
class
=
"style1"
>
016.
<?
017.
$sql
=
"select * from topic where topic_id = $topic order by topic_id DESC ;"
;
018.
$result
= mysql_query(
$sql
);
019.
020.
$row_result
= mysql_fetch_assoc(
$result
);
021.
022.
?>
023.
<?
024.
025.
026.
027.
echo
$row_result
[
'title'
];
028.
$topic
=
$row_result
[
'topic_id'
];
029.
030.
031.
?>
032.
</span></td>
033.
</tr>
034.
<tr>
035.
<td align=
"left"
valign=
"top"
>
036.
<?
echo
$row_result
[
'description'
]; ?>
037.
<div align=
"center"
><span
class
=
"style4"
>><a href=
"topic_update.php?topic=<? echo $topic; ?>"
>แก้ไข</a><</span><br />
038.
<br />
039.
</div></td>
040.
</tr>
041.
<tr>
042.
<td align=
"left"
valign=
"top"
><hr /></td>
043.
</tr>
044.
<tr>
045.
<td align=
"left"
valign=
"top"
><form id=
"form1"
name=
"form1"
method=
"post"
action=
"question_add.php?topic=<? echo $topic; ?>"
>
046.
<div align=
"center"
>
047.
<label> <span
class
=
"style4"
>*เลือกประเภทคำถาม</span><span
class
=
"style4"
>
048.
<select name=
"type"
id=
"type"
>
049.
<option value=
"01"
>คำถามแบบเปิด</option>
050.
<option value=
"02"
>คำถามแบบเลือกตอบ</option>
051.
<option value=
"03"
>คำถามแบบตรวจรายการ</option>
052.
<option value=
"04"
>คำถามแบบประเมินค่า</option>
053.
<option value=
"05"
>คำถามแบบใส่วันที่</option>
054.
<option value=
"06"
>คำถามแบบเรียงลำดับความสำคัญ</option>
055.
</select>
056.
</span></label>
057.
<span
class
=
"style4"
>
058.
<label>
059.
<input type=
"submit"
name=
"Submit"
value=
"เพิ่มหัวข้อใหม่"
/>
060.
</label>
061.
</span><span
class
=
"style3"
> </span>
062.
<input name=
"htopic_id"
type=
"hidden"
id=
"htopic_id"
value=
"<? echo $row_result['topic_id']; ?>"
/>
063.
</div>
064.
</form> </td>
065.
</tr>
066.
<tr>
067.
<td align=
"left"
valign=
"top"
> <div align=
"center"
><br />
068.
<br />
069.
</div></td>
070.
</tr>
071.
<tr> </tr>
072.
<tr>
073.
<td align=
"left"
valign=
"top"
><hr /></td>
074.
</tr>
075.
<tr>
076.
<td align=
"left"
valign=
"top"
> </td>
077.
</tr>
078.
</table>
079.
<form action=
"<?php echo $editFormAction; ?>"
method=
"post"
name=
"form2"
target=
"_blank"
class
=
"style4"
>
080.
<?
081.
$sql
=
"select * from question where topic_id = $topic order by ques_id;"
;
082.
083.
$resultmain
= mysql_query(
$sql
);
084.
085.
086.
?>
087.
<?
088.
while
(
$datamain
= mysql_fetch_array(
$resultmain
)) {
089.
090.
?>
091.
092.
<table width=
"501"
border=
"0"
align=
"center"
cellpadding=
"0"
cellspacing=
"6"
>
093.
<tr>
094.
<td width=
"483"
height=
"25"
align=
"left"
valign=
"middle"
bgcolor=
"#000033"
><span
class
=
"style8"
>แก้ไขคำถามแบบเลือกตอบ (กรอกข้อความ) </span> </tr>
095.
<tr>
096.
<td height=
"25"
align=
"left"
valign=
"middle"
>
097.
<label>
098.
<div align=
"center"
>
099.
<input name=
"ques_title"
type=
"text"
id=
"ques_title"
value=
"<?php echo $datamain['ques_title']; ?>"
size=
"50"
/>
100.
<input name=
"htopic_id"
type=
"hidden"
id=
"htopic_id"
value=
"<? echo $topic_id; ?>"
/>
101.
</div>
102.
</label>
103.
<div align=
"center"
></div> </tr>
104.
<tr>
105.
<td align=
"left"
valign=
"top"
><hr /></td>
106.
</tr>
107.
</table>
108.
109.
110.
<?php } ?>
111.
<table width=
"501"
border=
"0"
align=
"center"
cellpadding=
"0"
cellspacing=
"6"
>
112.
<tr>
113.
<td width=
"483"
height=
"25"
align=
"right"
valign=
"middle"
bgcolor=
"#000033"
><div align=
"left"
class
=
"style8"
>คำตอบ</div></td>
114.
</tr>
115.
<tr>
116.
<td height=
"25"
align=
"right"
valign=
"top"
bgcolor=
"#FFFFFF"
><div align=
"center"
>
117.
<p
class
=
"style1"
>
118.
119.
<?php
120.
121.
122.
$sql1
=
"SELECT * FROM choice WHERE ques_id = $ques_id order by choice_id;"
;
123.
$result1
= mysql_query(
$sql1
);?>
124.
125.
126.
<textarea name=
"item"
cols=
"50"
rows=
"5"
><?php
while
(
$data
= mysql_fetch_array(
$result1
))
echo
$data
[
'item'
]; { ?> </textarea>
127.
<input name=
"htopic_id"
type=
"hidden"
id=
"htopic_id"
value=
"<? echo $row_result['ques_id']; ?>"
/>
128.
<?php } ?>
129.
130.
</p>
131.
</div></td>
132.
</tr>
133.
134.
135.
<tr>
136.
<td align=
"center"
valign=
"top"
><hr /></td>
137.
</tr>
138.
139.
</table>
140.
141.
142.
<label></label>
143.
<label></label>
144.
<div align=
"center"
>
145.
<input type=
"submit"
name=
"Submit2"
value=
"อัพเดท"
/>
146.
<input type=
"hidden"
name=
"MM_update"
value=
"form1"
>
147.
</label>
148.
149.
<style type=
"text/css"
>
150.
<!--
151.
.style1 {
152.
color: #FFFFFF;
153.
font-weight: bold;
154.
}
155.
.style3 {font-size: xx-small}
156.
.style4 {font-size: small}
157.
.style5 {color: #FF0000}
158.
-->
159.
</style>
160.
</div>
161.
162.
<a href =
"javascript:history.go(-1);"
></a>
163.
</form>
164.
165.
<!-- InstanceEndEditable --></td>
166.
</tr>
167.
168.
</table></td>
169.
</tr>
170.
</table>
171.
</body>
172.
<!-- InstanceEnd --></html>
173.
<?php
174.
if
(
$_POST
[
'item'
]!=
""
){
175.
include_once
(
"connection.php"
);
176.
177.
$ques_id
= mysql_insert_id();
178.
179.
$choices
=
explode
(
"\n"
,
$_POST
[
'item'
]);
180.
181.
182.
for
(
$i
= 0;
$i
<
count
(
$choices
);
$i
++) {
183.
if
(
empty
(
$choices
[
$i
])) {
184.
continue
;
185.
}
186.
$up_edmem
=
"UPDATE choice SET item ='"
.
$_POST
['
$choices
[
$i
]
']."'
WHERE schedule_id =".
$_POST
[
'hidden'
];
187.
mysql_query(
$up_edmem
)
or
die
(mysql_error());
188.
}
189.
$qr_upmemed
=mysql_query(
$up_edmem
);
190.
if
(
$qr_upmemed
){
191.
echo
"<script> window.location='topic_show.php?topic="
.
$topic
.
"';</script>"
;
192.
}
193.
}
194.
?>