INSERT ข้อมูลไม่ลงฐานข้อมูลค่ะ รบกวนช่วยแนะนำหน่อยค่ะ ไม่แน่ใจว่าผิดตรงไหน

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: INSERT ข้อมูลไม่ลงฐานข้อมูลค่ะ รบกวนช่วยแนะนำหน่อยค่ะ ไม่แน่ใจว่าผิดตรงไหน

Re: INSERT ข้อมูลไม่ลงฐานข้อมูลค่ะ รบกวนช่วยแนะนำหน่อยค่ะ ไม่แน่ใจว่าผิดตรงไหน

โดย mindphp » 03/06/2018 5:13 pm

ใน loop for ยังไม่มี คำสั่ง mysqli_query

ลอง echo คำสั่ง sql ออกมาดูครับ
และโครงสร้างตาราง

INSERT ข้อมูลไม่ลงฐานข้อมูลค่ะ รบกวนช่วยแนะนำหน่อยค่ะ ไม่แน่ใจว่าผิดตรงไหน

โดย supattra_su » 03/06/2018 11:28 am

โค้ด: เลือกทั้งหมด

<?php

        $Act= isset($_GET['Act']);
          switch($Act){
                case 'Add'  :   $Cours=explode("#", isset($_POST['txtcourse']));
                                $Question=isset($_POST['txtQuestion']);
                                $Answer=isset($_POST['txtAnswer']);
                                $AnswerTrue=isset($_POST['txtAnswerTrue']);

    $insertQuestion = "INSERT INTO question(Course,Question,AnswerTrue,subject_id,ArticleID) VALUES ('.$Cours[0].','.$Question.','.$AnswerTrue.','.$Cours[1].','.$Cours[1].')"; 

      $resultQue  = mysqli_query($conn,$insertQuestion);

         /** $insertQuestion=insert("question","Course,Question,AnswerTrue,subject_id,ArticleID","'".$Cours
         [0]."','".$Question."','".$AnswerTrue."','".$Cours[1]."','".$Cours[1]."'"); **/

            if($resultQue)
                {
                  $QuestionID = mysql_insert_id();
                  for($i=0;$i<4;$i++)
                {
                  $insertAnswer = "INSERT INTO answer (QuestionID,Answer) VALUES ('$QuestionID','.$Answer[$i].')";   
                 /** $insertAnswer=insert("answer","QuestionID,Answer","'".$QuestionID."','".$Answer[$i]."'"); **/
                }

                echo "<script>";
                echo "alert('ระบบทำการเพิ่มคำถาม $Question เรียบร้อย');";
                echo "window.location='detail_question.php';";
                echo "</script>"; 

                }
    break;  
  }
?>

ข้างบน