<?php //////////////////////////////////////////////////////////editQuestion.php///////////////////////////////////////////////////////////// ob_start(); include "connect.php"; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> <!-- .style1 { font: Tahoma; color: #FFFFFF; font-weight: bold; font-size:18px; } --> </style> <? $ex_id = $_GET['ex_id']; $ques_id = $_GET['ques_id']; $sql = "select * from question where ex_id = '$ex_id' and ques_id = '$ques_id'"; $db_query = mysql_query($sql) or die ("Select error"); $result = mysql_fetch_array($db_query); $ques = $result[question]; $c1 = $result[choice1]; $c2 = $result[choice2]; $c3 = $result[choice3]; $c4 = $result[choice4]; $ans = $result[answer]; $sc = $result[score]; ?> <form id="form1" name="form1" method="post" action="editQuestionSave.php"> <table width="580" border="0" align="center"> <tr> <td colspan="2" bgcolor="#000099"><div align="center" class="style1">แก้ไขคำถาม</div></td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>คำถาม</td> <td width="70%"><textarea name="ques" cols="50" rows="5" id="ques"> <? echo $ques;?></textarea></td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>ตัวเลือกที่ 1</td> <td width="70%"><input name="ch1" type="text" id="ch1" size="30" value="<? echo $c1;?>"/> </td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>ตัวเลือกที่ 2</td> <td width="70%"><input name="ch2" type="text" id="ch2" size="30" value="<? echo $c2;?>"/> </td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>ตัวเลือกที่ 3</td> <td width="70%"><input name="ch3" type="text" id="ch3" size="30" value="<? echo $c3;?>"/></td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>ตัวเลือกที่ 4</td> <td width="70%"><input name="ch4" type="text" id="ch4" size="30" value="<? echo $c4;?>"/></td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>คำตอบ</td> <td width="70%"><input name="ans" type="text" id="ans" size="2" maxlength="1" value="<? echo $ans;?>"/></td> </tr> <tr> <td width="30%" bgcolor='#AEFFFF'>คะแนน</td> <td><input name="score" type="text" id="score" size="2" maxlength="2" value="<? echo $sc;?>"/></td> </tr> <tr> <td width="30%"> </td> <td width="70%"> </td> </tr> <tr> <td colspan="2"><div align="center"> <input name="Submit" type="submit" value="แก้ไข" /> <input type="reset" name="Submit2" value="ยกเลิก" onClick="history.back();" /> </div></td> </tr> </table> <INPUT type="hidden" VALUE="<?=$ex_id;?>" name="ex_id"> <INPUT type="hidden" VALUE="<?=$ques_id;?>" name="ques_id"> </form> <? ob_end_flush(); mysql_close(); ?>
<?php ///////////////////////////////////////////////////////editQuestionSave.php////////////////////////////////////////////////////// ob_start(); include ("connect.php"); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <? //$qid = $_POST["quesID"]; $ex_id = $_POST["ex_id"]; $ques_id = $_POST["ques_id"]; $ques = $_POST["ques"]; $ch1 = $_POST["ch1"]; $ch2 = $_POST["ch2"]; $ch3 = $_POST["ch3"]; $ch4 = $_POST["ch4"]; $ans = $_POST["ans"]; $scr = $_POST["score"]; if(($ques=="")||($ch1=="")||($ch2=="")||($ch3=="")||($ch4=="")||($ans=="")||($scr=="")) { echo "<script>alert('กรอกข้อมูลไม่ครบ');history.back();</script>"; } else if(!is_numeric($ans)) { echo "<script>alert('คำตอบต้องเป็นตัวเลขเท่านั้น');history.back();</script>"; } else if(($ans=="0")||($ans=="5")||($ans=="6")||($ans=="7")||($ans=="8")||($ans=="9")) { echo "<script>alert('คำตอบต้องเป็นตัวเลข 1-4 เท่านั้น');history.back();</script>"; } else if(!is_numeric($scr)) { echo "<script>alert('คะแนนต้องเป็นตัวเลขเท่านั้น');history.back();</script>"; } $sql = "select * from question where ex_id='$ex_id' and ques_id='$ques_id'"; $db_query = mysql_query($sql) or die ("Select error"); $count = mysql_num_rows($db_query); if($count==0) { echo "<script>alert('ไม่มีข้อมูลนี้');history.back();</script>"; } else { $sql = "update question set question='$ques',choice1='$ch1',choice2='$ch2',choice3='$ch3',choice4='$ch4',answer='$ans',score='$scr'"; $result = mysql_query($sql) or die("Update error"); echo "<script>alert('แก้ไขแบบทดสอบเรียบร้อยแล้ว');history.back();</script>"; } ob_end_flush(); mysql_close(); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง