title: Multiple dropdown values to create SQL query PHP
body: <p>I am currently tring to create a form wherein there is three dropdown option boxes and one submit button. All three of the dropdown boxes are populated from the database and I would like the selected options to be included into a new query and printed. <em>This example only shows one dropdown</em></p>
  
  <p>PHP Code</p>
  
  <pre><code>// Create connection
  $con=mysqli_connect('', '', '', '');
  
  // Check connection
  if (mysqli_connect_errno($con))
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $course_dropdown ="";
  $query_course = "SELECT * FROM course";
  $result_course = mysqli_query($con,$query_course) or die(mysqli_error());
  
  while($row = mysqli_fetch_assoc($result_course))
  {
      $course_dropdown .= "&lt;option value='{$row['CourseName']}'{$row['CourseName']}           &lt;/option&gt;";
  }
  </code></pre>
  
  <p>Above is the code that is used to create the dropdown lists</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form="index.php" method="post"&gt;
  &lt;select name="Course"&gt;&lt;?php echo $course_dropdown; ?&gt;&lt;/select&gt;
  &lt;input name="button" value="Submit" type="submit"&gt;
  </code></pre>
  
  <p>I am at a loss over what way to proceed, I have tried various different techniques but cannot come up with an answer.</p>
  
  <p>Latest attempt</p>
  
  <pre><code>$course = mysqli_real_escape_string($con, $_POST['Course']);
  $query = mysqli_query($con,"SELECT * FROM course_module WHERE CourseName = $course"); 
  </code></pre>
  
  <p>this brought an error </p>
  
  <p><em>Notice: Undefined index: Course in C:\Users\seanin\Desktop\xampp\htdocs\index.php on line 33</em></p>
  
  <p>So have edited as suggested and stil have an error, may be missing something small.</p>
  
  <pre><code>// Check connection
  if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $course_dropdown ="";
  $query_course = "SELECT * FROM course";
  $result_course = mysqli_query($con,$query_course) or die(mysqli_error());
  
  while($row = mysqli_fetch_assoc($result_course))
  {
  $course_dropdown .= "&lt;option value='{$row['CourseName']}'&gt;{$row['CourseName']}&lt;/option&gt;";
  } 
  
  if ($_POST['button'] == 'Submit') {
  $course = mysqli_real_escape_string($con, $_POST['Course']);
  $query = mysqli_query($con,"SELECT * FROM course_module WHERE CourseName = $course"); 
  }
  </code></pre>
  
  <p>Still have this error</p>
  
  <p><em>Notice: Undefined index: button in C:\Users\seanin\Desktop\xampp\htdocs\index.php on line 30</em></p>
  
  <p>submit button issue</p>
  
  <hr>
  
  <p>Nearly done, thanks for all the help so far.</p>
  
  <p>What do I need to do to get the results and print them???</p>