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

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

supattra_su
PHP Full Member
PHP Full Member
โพสต์: 39
ลงทะเบียนเมื่อ: 18/05/2018 10:21 pm

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

โพสต์ที่ยังไม่ได้อ่าน โดย 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;  
  }
?>
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

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

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

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

ลอง echo คำสั่ง sql ออกมาดูครับ
และโครงสร้างตาราง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 104