title: How to Display SQL Column Data in an Input Value
body: <p>So far I have the code </p>
  
  <pre><code>if (isset($_GET["job_pos_sort"])) {
       $sn = (int)($_GET["job_pos_sort"]);
  </code></pre>
  
  <p><code>$job_posname = "SELECT job_pos FROM careers WHERE job_pos_sort = $sn";</code></p>
  
  <p>and </p>
  
  <pre><code>&lt;td&gt;&lt;input name="job_pos_sort" type="text" id="job_pos_sort" value="&lt;?php echo $sn;?&gt;"&gt;&lt;/td&gt;
  
  &lt;td&gt;&lt;input name="job_pos" type="text" id="job_pos" value="&lt;?php echo $job_posname;?&gt;"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>and the code displays the job_pos_sort input value correctly. I am trying to make the job_pos value display correctly in the second input. The second input value appears blank on my web page.</p>
  
  <p>My web page URL looks like this : mywebpage.ca/phptester/updatecareers.php?job_pos_sort=4</p>
  
  <p>Here is my whole code:</p>
  
  <pre><code>&lt;?php
  $dbhost = 'ddsehdscom';
  $dbuser = 'kedsagbm';
  $dbpass = 'Kisazer';
  $dbname = 'kedsgbm';
  $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  if(! $conn )
  {
    die('Could not connect: ' . mysqli_error());
  }
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Update a Record in MySQL Database&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  if (isset($_GET["job_pos_sort"])) {
      $sn = (int)($_GET["job_pos_sort"]);
  if(isset($_POST['update']))
  {
  $job_pos_sort = $_POST['job_pos_sort'];
  $job_pos = $_POST['job_pos'];
  
  $sql = "UPDATE careers ".
         "SET job_pos = '$job_pos' ".
         "WHERE job_pos_sort = $job_pos_sort" ;
  
  $retval = mysqli_query($conn, $sql);
  if(! $retval )
  {
    die('Could not update data: ' . mysqli_error());
  }
  echo "Updated data successfully\n";
  echo "Click &lt;a href='displaydb.php'&gt;here&lt;/a&gt; to return to the table";
  
  }
  else
  {
  $job_posname = "SELECT job_pos FROM careers WHERE job_pos_sort = $sn";
  $query=mysqli_query($conn, $job_posname);
  $array=mysqli_fetch_assoc($query);
  $job_posname=stripslashes($array['job_pos']);
  ?&gt;
  &lt;form method="post" action=""&gt;
  &lt;table width="400" border="0" cellspacing="1" cellpadding="2"&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt;Employee ID&lt;/td&gt;
  &lt;td&gt;&lt;input name="job_pos_sort" type="text" id="job_pos_sort" value="&lt;?php echo $sn;?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt;Employee Salary&lt;/td&gt;
  &lt;td&gt;&lt;input name="job_pos" type="text" id="job_pos" value="&lt;?php echo $job_posname;?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt; &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt; &lt;/td&gt;
  &lt;td&gt;
  &lt;input name="update" type="submit" id="update" value="Update"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;?php
  }
  }
  else {
          echo ("No employee id given.");
  }
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank you, for any help.</p>
  
  <p>Kelsey</p>