01.
<?php
02.
03.
$quiz_id
=
intval
(
$_GET
[
'quiz_id'
]);
04.
$board_quiz
=mysql_query(
"select * from board_quiz where quiz_id="
.
$quiz_id
);
05.
$quiz
=mysql_fetch_assoc(
$board_quiz
);
06.
07.
08.
if
(!
empty
(
$_POST
[
'answer'
])){
09.
$quiz_id
=mysql_real_escape_string(
$_POST
[
'quiz_id'
]);
10.
$ans_detail
=mysql_real_escape_string(
$_POST
[
'ans_detail'
]);
11.
$ans_name
=mysql_real_escape_string(
$_POST
[
'ans_name'
]);
12.
13.
$cmd
=
"insert into board_ans (quiz_id,ans_detail,ans_name,ans_date) values ('$quiz_id','$ans_detail','$ans_name',now())"
;
14.
$strQuery
=mysql_query(
$cmd
);
15.
if
(
$strQuery
){
16.
echo
"<script>alert('บันทึกข้อมูลสำเร็จ'); window.location='index.php?page=webboard_view.php&quiz_id=$quiz_id';</script>"
;
17.
}
18.
}
19.
?>
20.
21.
<div style=
"padding:5px;"
><a href=
"index.php?page=webboard.php"
>เว็บบอร์ด</a> > แสดงรายละเอียด</div>
22.
<table width=
"100%"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
bordercolor=
"#2F98BB"
>
23.
<tr>
24.
<td bgcolor=
"#2F98BB"
style=
"padding:4px; color:#FFFFFF; font-size:14px; border-radius:5px;"
><strong>TOPIC</strong> : <?=
$quiz
[
'quiz_topic'
];?></td>
25.
</tr>
26.
<tr>
27.
<td style=
"padding:4px;"
><?php
echo
$quiz
[
'quiz_detail'
];?></td>
28.
</tr>
29.
<tr>
30.
<td bgcolor=
"#cccccc"
style=
"padding:4px; font-style:italic; color:#000; font-weight:bold;"
>By. <?=
$quiz
[
'quiz_name'
];?> E-Mail : <?=
$quiz
[
'quiz_email'
];?>
Date
: <?=
$quiz
[
'quiz_date'
].
" "
.
$quiz
[
'quiz_time'
];?></td>
31.
</tr>
32.
</table>
33.
34.
<!--post ans quiz-->
35.
<h2>ตอบคำถาม</h2>
36.
<form action=
"#"
method=
"post"
>
37.
<table width=
"100%"
border=
"0"
cellspacing=
"3"
cellpadding=
"3"
>
38.
<tr>
39.
<td>รายละเอียด<br>
40.
<textarea name=
"ans_detail"
id=
"ans_detail"
cols=
"70"
rows=
"5"
></textarea></td>
41.
</tr>
42.
<tr>
43.
<td>ชื่อ<br><input type=
"text"
name=
"ans_name"
id=
"ans_name"
class
=
"input_text"
></td>
44.
</tr>
45.
<tr>
46.
<td>
47.
<input type=
"submit"
name=
"answer"
id=
"button"
value=
"ตกลง"
class
=
"input_submit"
>
48.
<input type=
"reset"
name=
"button2"
id=
"button2"
value=
"ยกเลิก"
class
=
"input_submit"
>
49.
<input type=
"hidden"
name=
"quiz_id"
value=
"<?=$quiz_id;?>"
></td>
50.
</tr>
51.
</table>
52.
</form>
53.
<h2>คำตอบล่าสุด</h2>
54.
<?php
55.
$sql
=
"select count(*) from board_ans"
;
56.
$rs
=mysql_query(
$sql
);
57.
$total_rec
=mysql_result(
$rs
,0,0);
58.
$p_size
=10;
59.
$total_page
=(int)(
$total_rec
/
$p_size
);
60.
61.
if
((
$total_rec
%
$p_size
)!=0){
62.
$total_page
++;
63.
}
64.
if
(
empty
(
$_GET
[
'pages'
])){
65.
$page
=1;
66.
$start
=0;
67.
}
else
{
68.
$page
=
$_GET
[
'pages'
];
69.
$start
=
$p_size
*(
$page
-1);
70.
}
71.
72.
$board_ans
=mysql_query(
"select * from board_ans where quiz_id=$quiz_id order by ans_id desc limit $start , $p_size"
);
73.
$num
=mysql_num_rows(
$board_ans
);
74.
while
(
$row
=mysql_fetch_assoc(
$board_ans
)){
75.
?>
76.
<table width=
"100%"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
bordercolor=
"#2F98BB"
bgcolor=
"#CCCCCC"
>
77.
<tr>
78.
<td bgcolor=
"#2F98BB"
style=
"padding:4px; color:#FFFFFF; font-size:14px; border-radius:5px;"
><strong>ตอบโดย </strong> : <?=
$row
[
'ans_name'
];?> เมื่อ : <?=
$row
[
'ans_date'
];?></td>
79.
</tr>
80.
<tr>
81.
<td style=
"padding:4px;"
><?php
echo
$row
[
'ans_detail'
];?></td>
82.
</tr>
83.
</table>
84.
<hr>
85.
<? } ?>
86.
87.
<?
88.
echo
"Total : "
.
$num
.
" Record Page ::"
;
89.
for
(
$i
=1;
$i
<=
$total_page
;
$i
++){
90.
echo
" <a href=index.php?page=webboard.php&pages="
.
$i
.
">["
.
$i
.
"]</a> "
;
91.
}
92.
?>