<?php include_once "../function/chk_login.php"; //--------------- ลบข้อมูล -----------------// if($_GET['action'] == "delete") { $del = mysql_query("DELETE FROM tb_score WHERE score_id='".$_GET["score_id"]."'"); if(!del) { echo mysql_error(); } else { echo"<script language='JavaScript'>"; echo"alert('ข้อมูลถูกลบแล้ว');"; echo"window.location='admin_page.php?url=score.php';"; echo"</script>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="../css/style.css" /> </head> <body> <div style="margin-bottom:20px;"><strong class="HeaderText">ผลสอบของสมาชิก</strong></div> <?php include_once "../function/paging.php"; $sql = "SELECT * FROM ((tb_score INNER JOIN tb_member ON tb_member.user_id = tb_score.user_id)INNER JOIN tb_question_group ON tb_score.question_group_id=tb_question_group.question_group_id)"; $rs = mysql_query($sql); //--------------- แบ่งหน้า -------------------// $Num_Rows = mysql_num_rows($rs); $Per_Page = 20; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $sql .=" order by tb_member.user_id = tb_score.user_id DESC LIMIT $Page_Start , $Per_Page"; $rs = mysql_query($sql); ?> <!-------- หัวข้อ -------> <div style="width:590px;" class="BodyStyle" align="center"> <div style="width:100px;" class="border_data_head"><strong>รหัสนักเรียน</strong></div> <div style="width:200px;" class="border_data_head"><strong>ชื่อ-นามสกุล</strong></div> <div style="width:80px;" class="border_data_head"><strong>ข้อสอบ</strong></div> <div style="width:80px;" class="border_data_head"><strong>คะแนนสอบ</strong></div> <div style="width:50px;" class="border_data_head"><strong>ลบ</strong></div> </div> <!-------- รายละเอียด ----------> <div class="clear"></div> <?php if(!empty($rs)): ?> <?php while ($r = mysql_fetch_assoc($rs)): ?> <div style="width:590px;" class=" BodyStyle"> <div style="width:100px;" class="border_data"><?php echo $r["user_id"]; ?></div> <div style="width:200px;" class="border_data" align="left"><?php echo $r["name"]; ?></div> <div style="width:80px;" class="border_data"><?php echo $r["question_group_name"]; ?></div> <div style="width:80px;" class="border_data"><?php echo $r["score_total"]; ?></div> <div style="width:50px;" class="border_data"><a href="admin_page.php?url=score.php&score_id=<?php echo $r["score_id"]; ?>&action=delete" onClick="return confirm ('ยืนยันการลบ')"><img src="../images/delete.png" border="0"></a></div> </div> <?php endwhile ?> <?php endif ?> <!-------- แสดงแบ่งหน้า ----------> <div class="clear"></div> <div class="paging_space"> <? $pages = new Paginator; $pages->items_total = $Num_Rows; $pages->mid_range = 10; $pages->current_page = $Page; $pages->default_ipp = $Per_Page; $pages->url_next = "admin_page.php?url=score.php&QueryString=value&Page="; $pages->paginate(); echo $pages->display_pages() ?> </div> <?php include_once "../mysql_close.php"; ?> </body> </html>
<? include_once "connect.php"; include_once "function/chk_login_user.php"; $question_group_id = $_GET["question_group_id"]; //======== นับจำนวนคะแนนสอบ ==========// $score_total=0; for($i=1;$i<=$_POST["line"];$i++) { If($_POST["c$i"] == $_POST["answer$i"]) { $score_total=$score_total+1; } } echo "<div class='RedText'><b>คุณตอบถูกไป $score_total คะแนน</b></div>"; //echo "ผลการสอบได้คะแนนรวม $score_total<br>"; //=========================================// /* echo $_SESSION["user_id"]; ///// echo เช็คว่ามีข้อมูลหรือไม่ echo $score_id; ///// echo เช็คว่ามีข้อมูลหรือไม่ echo $score_total; ///// echo เช็คว่ามีข้อมูลหรือไม่ */ //query if($_SESSION["user_id"] != "") { $sql = "INSERT INTO tb_score(user_id,score_total,question_group_id) VALUES ('$_SESSION[user_id]','$score_total','$question_group_id')"; $res = mysql_query($sql,$conn); } else { //update $sql = "UPDATE tb_score SET user_id = '$_SESSION[user_id]', score_total = '$score_total', question_group_id = '$question_group_id' "; $res = mysql_query($sql,$conn); } ?>
Quote:order by tb_member.user_id = tb_score.user_id DESC
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง