title: update database field based on what the user selects via dropdown
body: <p>so on my site, the admin can assign a job to a user and that job will automatically have the status: waiting to be accepted. I have now created a drop down box on the job page so that the user can either decline or accept the job with that drop down box. however im unsure of the coding needed to update the database field based on what the user selects.</p>
  
  <p>what im aiming for is: the user selects a status, then clicks the change button to update the status of the job.</p>
  
  <p>current code:</p>
  
  <pre><code>   &lt;?php
          if(!isset($_SESSION)) 
          { 
              session_start(); 
          } 
      ?&gt;
  
  
  
      &lt;!DOCTYPE html&gt;
      &lt;html&gt;
          &lt;head&gt;
             &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;!-- Latest compiled and minified CSS --&gt;
  
              &lt;title&gt;Tyre Hire&lt;/title&gt;
              &lt;link rel="stylesheet" type="text/css" href="css/mystyle.css"/&gt;
          &lt;!-- Latest compiled and minified CSS --&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  
      &lt;!-- jQuery library --&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;!-- Latest compiled JavaScript --&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
          &lt;div class="col-xs-12"&gt;
  
              &lt;header&gt; 
                  &lt;img class="img-responsive" src ="images/Logo.png" alt ="logo"/&gt;
              &lt;/header&gt;
  
          &lt;/div&gt;
          &lt;/div&gt;
  
                  &lt;?php
  
                  require_once ("config.inc.php");
  
      try
          {
          $conn = new PDO(DB_DATA_SOURCE, DB_USERNAME, DB_PASSWORD);
          }
  
      catch(PDOException $exception)
          {
          echo "Oh no, there was a problem" . $exception-&gt;getMessage();
          }
  
                  if(!isset($_SESSION["username"]))
      {
          //user tried to access the page without logging in
          header( "Location: add.php" );
  
      }
  
          $login = $_SESSION['user_ID'];
  
          $query = "SELECT * FROM login WHERE user_ID = :user_ID"; 
      $term = $conn-&gt;prepare($query);
      $term-&gt;bindValue(':user_ID', $login);
      $term-&gt;execute();
  
      $login = $term-&gt;fetch(PDO::FETCH_OBJ);      
  
  
      $status = "Waiting to be accepted";
      $status2 = "Accept Job";
      $status3 = "Decline Job";
  
      if(isset($_SESSION["username"]))
      {
          echo "Welcome, you are now logged in as &lt;b&gt;".$_SESSION['username']."&lt;/b&gt; &lt;img class='clientView' src='images/loginIcon.png' alt='client'&gt;"; }
          else { 
          echo "You are currently not logged in";
          };
  
          ?&gt;
          &lt;div class="row"&gt;
                  &lt;div class="col-xs-12"&gt;
          &lt;br&gt;
              &lt;nav class="navbar navbar-inverse"&gt;
        &lt;div class="container-fluid"&gt;
          &lt;div class="navbar-header"&gt;
            &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;                        
            &lt;/button&gt;
            &lt;a class="navbar-brand" href="main.php"&gt;Tyre Hire&lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="collapse navbar-collapse" id="myNavbar"&gt;
            &lt;ul class="nav navbar-nav"&gt;
  
                      &lt;li&gt;&lt;a href="main.php"&gt; Home &lt;span class="glyphicon glyphicon-print"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                     &lt;li&gt;&lt;a href="search.php"&gt; Search &lt;span class="glyphicon glyphicon-print"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;?php echo "&lt;a href='all-jobs.php?user_id=" . $login-&gt;user_ID . "&amp;occupation=". $login-&gt;occupation ."''&gt; Current Jobs &lt;span class='glyphicon glyphicon-print'&gt;&lt;/span&gt;&lt;/a&gt;";?&gt; &lt;/li&gt;
                       &lt;li&gt;&lt;a href="interest.php"&gt; Register Interest &lt;span class="glyphicon glyphicon-print"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                     &lt;li&gt;&lt;a href="logout.php"&gt; Logout &lt;span class="glyphicon glyphicon-print"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
            &lt;ul class="nav navbar-nav navbar-right"&gt;
              &lt;li&gt;&lt;a href="account.php"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; Sign Up&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="add.php"&gt;&lt;span class="glyphicon glyphicon-log-in"&gt;&lt;/span&gt; Login&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/nav&gt;
          &lt;/div&gt;
          &lt;/div&gt;
              &lt;div class="row"&gt;
          &lt;div class="col-xs-12"&gt;
              &lt;div class="right"&gt;
                  &lt;h2&gt;Current Jobs&lt;/h2&gt;
                  &lt;p&gt;One of the best sites to find the best qualified and skilled drivers in the UK.&lt;/p&gt;
  
  
                              &lt;form class="form-horizontal formApply"  action="" method="POST"&gt;
              &lt;h2&gt;&lt;u&gt;Job Details &lt;/u&gt;&lt;/h2&gt;
  
          &lt;div class="form-group"&gt;
  
      &lt;?php
  
          echo "&lt;h3&gt;Job role :".$worker-&gt;jobTitle."&lt;/h3&gt;";
  
      echo "&lt;ul&gt;";
      echo "&lt;h3&gt; About the role &lt;/h3&gt;";
      echo "&lt;li&gt;&lt;b&gt;Company Name:&lt;/b&gt;".$worker-&gt;company."&lt;/li&gt;";
  
      echo "&lt;li&gt;&lt;b&gt;Job Description:&lt;/b&gt;".$worker-&gt;jobDescription."&lt;/li&gt;";
      echo "&lt;h3&gt;shift pattern&lt;/h3&gt;";
      echo "&lt;li&gt;&lt;b&gt;Start Time: &lt;/b&gt;".$worker-&gt; startTime."&lt;/li&gt;";
      echo "&lt;li&gt;&lt;b&gt;End Time: &lt;/b&gt;".$worker-&gt; endTime."&lt;/li&gt;";
      echo "&lt;br /&gt;";
      echo "&lt;li&gt;&lt;b&gt;start Date:&lt;/b&gt;".$worker-&gt;startDate."&lt;/li&gt;";
      echo "&lt;li&gt;&lt;b&gt;Job Expiry Date:&lt;/b&gt;".$worker-&gt;expiry."&lt;/li&gt;";
      echo "&lt;b&gt;&lt;h4&gt;Current Status: &lt;/b&gt;".$worker-&gt;status."&lt;/h4&gt;";
      echo "&lt;/ul&gt;";
  
  
  
  
      ?&gt;
       &lt;div class="form-group"&gt;
       &lt;label class="control-label col-sm-2" for="search"&gt; Status&lt;/label&gt;
          &lt;div class="col-sm-3"&gt;
  
              &lt;select class="form-control" name="status" &gt; 
              &lt;option value="&lt;? echo $status;?&gt;"&gt;&lt;?php echo $status;?&gt;&lt;/option&gt;
              &lt;option value="&lt;? echo $status2;?&gt;"&gt;&lt;?php echo $status2;?&gt;&lt;/option&gt;
              &lt;option value="&lt;? echo $status3;?&gt;"&gt;&lt;?php echo $status3;?&gt;&lt;/option&gt;
              &lt;/select&gt; 
  
              &lt;input type="hidden" value="&lt;?php echo $status; ?&gt;" name="status"&gt;
  
      &lt;/div&gt;
  
       &lt;div class="form-group"&gt;
   &lt;!--&lt;label class="control-label col-sm-2" for="search"&gt;&lt;/label&gt;      --&gt;
      &lt;div class="col-sm-3"&gt;
  
      &lt;!--    &lt;select class="form-control" name="status" &gt; 
          &lt;option value="&lt;? echo $job;?&gt;"&gt;&lt;?php echo $job;?&gt;&lt;/option&gt;
          &lt;/select&gt;  --&gt;
  
          &lt;input type="hidden" value="&lt;?php echo $job; ?&gt;" name="job_id"&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  
      &lt;/div&gt;
      &lt;input class = "buttonA" type="submit" name="Apply" value="Change status"/&gt; 
              &lt;/div&gt;          
  
  
  
  
  
  
  
      &lt;/form&gt;
  
              &lt;/div&gt;  
  
  
              &lt;/div&gt;
              &lt;/div&gt;
  
  
  
  
              &lt;div class="row"&gt;
               &lt;div class="col-xs-12"&gt;
              &lt;div id="BottomArea"&gt;
              &lt;h4&gt; Recruitment Agencies &lt;/h4&gt; 
              &lt;div class="row"&gt;
               &lt;div class="col-xs-3"&gt;
              &lt;img class="FxPic img-responsive" src="images/fxpic.png" alt="fx-logo"&gt;
              &lt;/div&gt;
               &lt;div class="col-xs-3"&gt;
              &lt;img class="driverhire img-responsive"  src="images/driverhire.jpg" alt="driverhire"&gt;
              &lt;/div&gt;
               &lt;div class="col-xs-3"&gt;
              &lt;img class="logi img-responsive" src="images/logi.png" alt="logi-logo"&gt;
              &lt;/div&gt;
               &lt;div class="col-xs-3"&gt;
              &lt;img class="pebble img-responsive" src="images/noel.png" alt="pebbles"&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;/div&gt;
  
              &lt;div class="row"&gt;
               &lt;div class="col-xs-12"&gt;
              &lt;footer&gt;
              &lt;img id="logoFoot" src ="images/Logo.png" alt ="logo"/&gt;
                  &lt;p&gt;&lt;b&gt;Address: 5A twickenham road, london SJ5 7AE&lt;/b&gt;&lt;/p&gt;
              &lt;/footer&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;script src=myjs.js&gt;&lt;/script&gt;
          &lt;/div&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>attempted it after reading the update manual, no errors but upon clicking the button it gives a blank page.:</p>
  
  <pre><code>   &lt;?php
  include ("db_fncs.php");
  try{
         $conn = new PDO(DB_DATA_SOURCE, DB_USERNAME, DB_PASSWORD);
  
  }
  catch (PDOException $exception) 
  {
  echo "Oh no, there was a problem" . $exception-&gt;getMessage();
  }
  
  
  $status = $_POST["status"];
  $job = $_POST['job_id'];
  print_r($_POST);
  
  $query = "UPDATE jobs SET status = :status WHERE job_id = :job_id AND status = :status";
  
  
      // Prepare statement
      $stmt = $conn-&gt;prepare($query);
  $stmt-&gt;bindValue(':status', $status);
  $stmt-&gt;bindValue(':job_id', $job);
      // execute the query
      $stmt-&gt;execute();
      //$stmt-&gt;commit();
   echo $stmt-&gt;rowCount() . " records UPDATED successfully";
  ?&gt;
  </code></pre>