<form id="crteTitle" name="crteTitle" action="insert/useTitle.php" method="post"> <!-- action="insert/useTitle.php" method="post" --> <!-- +++++++++แก้ไข action ไปใช้ path ที่ตั้งไว้++++++++++++--> <!-- เก็บ form --> <input type="hidden" name="txtFrmId" value="<?php echo $fromId ?>"> <!-- Table Assessment --> <div class="table-responsive"> <table class="table align-items-center table-flush"> <thead class="thead-light"> <tr> <th scope="col" rowspan="2" width="80%"> <center> <h2>เลือกหัวข้อหลักประเมิน</h2> </center> </th> <th scope="col" colspan="5"> <center> <h3>ระดับความพึงพอใจ</h3> </center> </th> </tr> <tr> <th scope="col"> <center> <h1><i class="fas fa-grin-alt fontColor-grin-alt"></i></h1> <h5>ดีมาก</h5> <h5>5</h5> </center> </th> <th scope="col"> <center> <h1><i class="fas fa-smile fontColor-smile"></i></h1> <h5>ดี</h5> <h5>4</h5> </center> </th> <th scope="col"> <center> <h1><i class="fas fa-meh fontColor-meh"></i></h1> <h5>ปานกลาง</h5> <h5>3</h5> </center> </th> <th scope="col"> <center> <h1><i class="fas fa-frown-open fontColor-frown-open"></i></h1> <h5>พอใช้</h5> <h5>2</h5> </center> </th> <th scope="col"> <center> <h1><i class="fas fa-angry fontColor-angry"></i></h1> <h5>ปรับปรุง</h5> <h5>1</h5> </center> </th> </tr> </thead> <tbody class="list"> <?php $numTitle = 0; $sqlTitle = "SELECT * FROM AssSecMas where SecStaNum <> 'D'"; $qryTitle = sqlsrv_query($connect, $sqlTitle); $i = 0; while ($row = sqlsrv_fetch_array($qryTitle, SQLSRV_FETCH_ASSOC)) { $numTitle++; $titleId = $row['SecNum']; $titleName = $row['SecNam']; ?> <tr> <th class="bg-secondary" scope="col" colspan="6"> <input type="hidden" name="titleId[]" value="<?php echo $titleId ?>"> <div class="custom-control custom-checkbox mb-3"> <input class="custom-control-input" value="Y" id="customCheck_<?php echo $numTitle ?>" //ส่วนcheckbox name="customCheck[]" type="checkbox"> <label class="custom-control-label" for="customCheck_<?php echo $numTitle ?>"> <h4> <?php echo $titleName ?></h4> </div> </th> </tr> <?php } ?> </tbody> </table> <a class="btn btn-twitter btn-lg btn-block text-white" onclick="insertTitle();"><i class="fas fa-plus"></i> เพิ่มหมวดการประเมิน</a> </div> </div> <h3>ข้อเสนอแนะเพิ่มเติม...</h3> <textarea class="form-control" id="txtcomment" name="txtcomment" rows="3" placeholder="Write a large text here ..." disabled></textarea> <br> <style> h6 { color: white; font-size: medium; } </style> <center> <p id="demo"></p> <input type="hidden" name="depMake" value="<?php echo $depMake ?>"> <button type="submit" name="submit" class="btn btn-primary btn-lg btn-block"> <h6>ถัดไป <i class="fas fa-arrow-right"></i></h6> </button> </center> <br> <br> </form> </html>
<?php if (isset($_POST['customCheck'])) { session_start(); require_once("../../include/connect.php"); $USUidCod = $_SESSION["username"]; $USFrmNum = $_POST["txtFrmId"]; $USDepNum = $_POST["depMake"]; $USAcpDte = date("YmdHis"); $ConTit = count($_POST["titleId"]); for ($i = 0; $i < $ConTit; $i++) { //loop จำนวนคำถามทั้งหมด $Status = isset($_POST['customCheck'][$i]) ? 'Y' : 'N'; $TitId = $_POST['titleId'][$i]; echo $TitId . " " . $Status . "<br>"; } } if (isset($qry)) { echo 'ok'; } ?>
<input class="custom-control-input" value="<?=$numTitle?>" id="customCheck_<?=$numTitle?>" helpRemember="ส่วนcheckbox" name="customCheck[]" type="checkbox" >
$cuschk = isset($_POST['customCheck']) ? $_POST['customCheck'] : []; // สร้างตัวแปรมารับค่าการเช็ต ถ้าไม่มีให้กำหนดเป็น array ว่าง // ถ้าไม่มีการเช็คเลย มันจะไม่มี ตัวแปร customCheck ส่งมาด้วยแม้แต่ค่าว่าง foreach ($_POST['titleId'] as $key=>$Title) { //loop เปลี่ยนจาก for เป็น foreach $Status = in_array($Titld, $cuschk) ? 'Y' : 'N'; echo $TitId . " " . $Status . "<br>"; }
$cuschk = isset($_POST['customCheck']) ? $_POST['customCheck'] : []; // สร้างตัวแปรมารับค่าการเช็ต ถ้าไม่มีให้กำหนดเป็น array ว่าง // ถ้าไม่มีการเช็คเลย มันจะไม่มี ตัวแปร customCheck ส่งมาด้วยแม้แต่ค่าว่าง foreach ($_POST['titleId'] as $key=>$Title) { //loop เปลี่ยนจาก for เป็น foreach $Status = in_array($Title, $cuschk) ? 'Y' : 'N'; echo $Title . " " . $Status . "<br>"; }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง