title: it is not able to retrieve correct value from variable in WHERE clause
body: <p>below I hava query where it performs a query to find all of the Course Details from the database and display it in a drop down menu and then the course which is selected is display in a message using the <code>$outputcourse</code> variable:</p>
  
  <pre><code>    $sql = "SELECT CourseId, CourseNo, CourseName FROM Course ORDER BY CourseNo"; 
  
      $sqlstmt=$mysqli-&gt;prepare($sql);
  
      $sqlstmt-&gt;execute(); 
  
      $sqlstmt-&gt;bind_result($dbCourseId, $dbCourseNo, $dbCourseName);
  
      $courses = array(); // easier if you don't use generic names for data 
  
      $courseHTML = "";  
      $courseHTML .= '&lt;select name="courses" id="coursesDrop"&gt;'.PHP_EOL; 
      $courseHTML .= '&lt;option value=""&gt;Please Select&lt;/option&gt;'.PHP_EOL;  
  
      $outputcourse = ""; 
      $hiddencourse = ""; 
  
      while($sqlstmt-&gt;fetch()) 
      { 
      $course = $dbCourseId;
      $courseno = $dbCourseNo;
      $coursename = $dbCourseName; 
      $courseHTML .= "&lt;option value='".$course."'&gt;" . $courseno . " - " . $coursename . "&lt;/option&gt;".PHP_EOL;  
  
      if (isset($_POST['courses']) &amp;&amp; ($_POST['courses'] == $course)) {
      $outputcourse .= "&lt;p&gt;&lt;strong&gt;Course:&lt;/strong&gt; " . $courseno .  " - "  . $coursename . "&lt;/p&gt;";
      $hiddencourse .= "&lt;p&gt;&lt;input type='hidden' id='hiddencourse' value='". $courseno . " - " . $coursename ."'&gt;&lt;/p&gt;";
  }
  
      } 
  
      $courseHTML .= '&lt;/select&gt;';  
  </code></pre>
  
  <p>Now what I want to do is display the modules which does not belong in the course selected. Now my query works fine in php but the problem I am having is that if I use mysqli to run this query, it is unable to retireve the <code>$dbCourseId</code> variable in the where clause so the WHERE clause is incorrect.</p>
  
  <p>The WHERE clause was suppose to display the courseId which was suppose to be <code>1</code> but it keeps displaying <code>10</code>. If I choose a different course where the courseId should be <code>3</code>, it still outputs <code>10</code>. </p>
  
  <p>So what my question is that which variable should go in the bind->param() in the code below and how can I retireve the correct courseId of the selected course?</p>
  
  <p>Below is the code for the query:</p>
  
  <pre><code>$modulequery = "
  SELECT
  m.ModuleId, m.ModuleNo, m.ModuleName, m.Credits
  FROM
  Module m
  WHERE
  m.ModuleId NOT IN (
  SELECT cm.ModuleId
  FROM Course_Module cm
  WHERE cm.CourseId = ?
  )
  ORDER BY m.ModuleNo
  ";
  
  $moduleqrystmt=$mysqli-&gt;prepare($modulequery);
  // You only need to call bind_param once
  $moduleqrystmt-&gt;bind_param("i",$dbCourseId);
  // get result and assign variables (prefix with db)
  
  $moduleqrystmt-&gt;execute(); 
  
  $moduleqrystmt-&gt;bind_result($dbModuleId,$dbModuleNo,$dbModuleName,$dbCredits);
  
  $moduleqrystmt-&gt;store_result();
  
  $modulenum = $moduleqrystmt-&gt;num_rows();     
  
  echo $dbCourseId;
  </code></pre>