title: How to query multiple fields from database table and input into select box?
body: <p>So, I'm having some issues with calling two fields from a table and inputting them as one entry in a select box that will keep adding each entry in a while statement.  In simpler terms I have one field called firstname and the next lastname in a table called professors.  I need these fields combined and put together and each one inputted into a select box. Below is the code I have and I receive errors in dreamweaver at the bottom part when I start the while statement, so I know what I have isn't working but I'm having trouble figuring out why. I can't upload a picture with syntax highlighting because I just made my account and don't have enough reputation.  The parts of code that I'm only concerned with in this question are the beginning parts up to where I start the table, and down at the bottom where I declare the select box for professor and the loop to grab the first and last names that are in the table.  I've been reading many support solutions for similar problems but was unsuccessful.  If anyone has any tips or advice I'd be greatful.</p>
  
  <pre><code>$fprofessor = $_GET['p_firstname'];
  $lprofessor = $_GET['p_lastname'];
  $selected_professor=$fprofessor." ".$lprofessor;
  
  $qp = "SELECT p_id, p_firstname, p_lastname FROM professors WHERE p_firstname='$fprofessor' AND p_lastname='$lprofessor'";
  $rp = @mysqli_query($dbc, $qp);
  
  // Table header:
  echo '&lt;table align="center" cellspacing="0" cellpadding="5" width="auto"&gt;
  &lt;tr  bgcolor="' . $bg . '"&gt;
  &lt;td align="left"&gt;Section ID&lt;/td&gt;
  &lt;td align="left"&gt;Course Major&lt;/td&gt;
  &lt;td align="left"&gt;Course ID&lt;/td&gt;
  &lt;td align="left"&gt;Course Name&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr bgcolor="' . $bg . '"&gt;
      &lt;form action="add_courses.php" method="post"&gt;
      &lt;td align="left"&gt;&lt;input type="text" name="section_id" size="7" maxlength="7"/&gt;&lt;/td&gt;
      &lt;td align="left"&gt;&lt;select name="course_major"&gt;
      &lt;option value="TBA"&gt;-Select Major-&lt;/option&gt;
      &lt;option value="CIT"&gt;CIT&lt;/option&gt;
      &lt;option value="CSE"&gt;CSE&lt;/option&gt;
      &lt;option value="CIT/CSE"&gt;CIT/CSE&lt;/option&gt;&lt;/td&gt;
      &lt;td align="left"&gt;&lt;input type="text" name="course_id" size="3" maxlength="3"/&gt;&lt;/td&gt;
      &lt;td align="left"&gt;&lt;input type="text" name="course_name" size="15" maxlength="25"/&gt;&lt;/td&gt;
   &lt;/tr&gt;
  
  &lt;tr  bgcolor="' . $bg . '"&gt;
  &lt;td align="left"&gt;Professor&lt;/td&gt;
  &lt;td align="left"&gt;Available&lt;/td&gt;
  &lt;td align="left"&gt;Semester&lt;/td&gt;
  &lt;td align="left"&gt;Year&lt;/td&gt;
  
  &lt;/tr&gt;
  
  &lt;tr bgcolor="' . $bg . '"&gt;
  
  &lt;td align="left"&gt;&lt;select name="course_professor"&gt;
  &lt;option value="TBA"&gt;-Select Professor-&lt;/option&gt;'
  while ($row = mysqli_fetch_array ($rp, MYSQLI_NUM)) {
   echo'&lt;option value="'.$row[. $selected_professor .].'"&gt;'.$row[. $selected_professor .].'&lt;/option&gt;'
  };          
  echo'&lt;/td&gt;
  </code></pre>
  
  <p>So, I've revised the code to something that seems more fitting based on the suggestions I got.  Below is what I have now but I'm still receiving an error on the $qp variable and the while statement in this code</p>
  
  <pre><code>&lt;td align="left"&gt;&lt;select name="course_professor"&gt;'
  
  $qp = "SELECT p_id, p_firstname, p_lastname, CONCAT(p_firstname, p_lastname) AS p_fullname FROM professors";
  $rp = @mysqli_query($dbc, $qp);
  
  echo '&lt;option value="TBA"&gt;-Select Professor-&lt;/option&gt;'
  while ($row = mysqli_fetch_array ($rp)) {   
  echo '&lt;option value="'.$row['p_fullname'].'"&gt;'.$row['p_fullname'].'&lt;/option&gt;'
  };
  
  
  echo'&lt;/td&gt;
  </code></pre>