หน้า 1 จากทั้งหมด 1

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

โพสต์แล้ว: 03/06/2018 11:28 am
โดย supattra_su

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

<?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;  
  }
?>

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

โพสต์แล้ว: 03/06/2018 5:13 pm
โดย mindphp
ใน loop for ยังไม่มี คำสั่ง mysqli_query

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