title: Using SELECT from WHILE as value in html input PHP SQL
body: <p>I am a complete beginner, so please bear with me. This is just a test project I am putting together to try to teach myself some of the basics. </p>
  
  <p>I know that a lot of my commands are outdated and/or susceptible to injection, but I'd rather stick with this for now (many reasons).</p>
  
  <p>I just had a question about trying to use <code>SELECT</code> from <code>WHILE</code>, and figured that out and got it to echo the correct response on the page.</p>
  
  <p>Now, how do I make it <code>echo</code> that as a value for an HTML text box? It won't work, and I've tried to look for typos but I don't know what I am doing, frankly.</p>
  
  <p>I see that the <code>$studentid</code> and <code>$teacherinfo</code> show fine, I presume because they are normal variables. 
  Can I somehow define two more variables for first name and last name further up in the page so that I do not need to include so much code in each input (and to keep it from being buggy)?</p>
  
  <p>Here is my code for the page. The inputs will be hidden, but I have been making them text boxes for debugging purposes.</p>
  
  <pre><code>&lt;?php
  $connection = mysql_connect($serverName, $userName, $password) or die('Unable to connect to Database host' . mysql_error());
  $dbselect = mysql_select_db($dbname, $connection) or die("Unable to select database:$dbname" . mysql_error());
  
  $studentid = $_POST['student_id'];
  $teacherinfo = $_POST['teacher'];
  
  $result = mysql_query("SELECT `first_name` FROM `students` WHERE student_id = '$studentid'",$connection);
  ?&gt;
  &lt;/head&gt;
      &lt;body&gt;
          &lt;div align="center"&gt;
              &lt;form method="post" action="vote_post.php"&gt;
                  &lt;h1&gt;Vote for Teacher of the Month&lt;/h1&gt;
                  &lt;h4&gt;(step 2 of 2)&lt;/h4&gt;
                  &lt;h2&gt;Confirm the Information Below&lt;/h2&gt;
                  &lt;h5&gt;Student id: &lt;?php echo $studentid ?&gt;&lt;/br&gt;
                      Student first name: &lt;?php 
                          while($row = mysql_fetch_array($result)){
                              echo $row['first_name'];
                          }
                      ?&gt;
                      &lt;/br&gt;
                      Voted for: &lt;?php echo $teacherinfo ?&gt;
                  &lt;/h5&gt;
                  &lt;input type="text" name="student_id" value="&lt;?php echo $studentid; ?&gt;"/&gt;&lt;/br&gt;
                  &lt;input type="text" name="first_name" value="&lt;?php while($row = mysql_fetch_array($result)){
                      echo $row['first_name'];
                  } ?&gt;"/&gt;
                  &lt;/br&gt;
                  &lt;input type="text" name="last_name" value="&lt;?php while($row = mysql_fetch_array($result)){
                      echo $row['last_name'];
                  } ?&gt;"/&gt;
                  &lt;/br&gt;
                  &lt;input type="text" name="teacher" value="&lt;?php echo $teacherinfo; ?&gt;"/&gt;&lt;/br&gt;
                  &lt;input type="submit" value="Submit Vote" class="inputbutton"/&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;
              &lt;/form&gt;
  </code></pre>