title: How do I pass information from a database using PHP
body: <p>I have a database holding customer details, I want to view all these details in a table. I want an edit button beside each name, encase the admin needs to update a user name for example. When the admin click edit say for example on "jessica" row they will be brought to another page which will display all of jessicas details and the admin can update these and save them to the database. So far on my first page I have this: Its the posting to the next page I am struggling with:</p>
  
  <pre><code>&lt;?php
  
  
    // the preparation
    include ("dbConnect.php");
  
  $query = $db-&gt;prepare("select * from customer");
  $query-&gt;execute();
  
  // Display search result
  if (!$query-&gt;rowCount() == 0) {
  
      echo "&lt;table id=\"example\" style=\"font-family:arial;color:#ffffff;\" class=\"table table-striped table-bordered\" style=\"width:100%\"&gt;"; 
      echo "&lt;thead&gt;&lt;tr&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;ID&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Forename&lt;/th&gt;                
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Surname&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Telephone&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Address&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Medical Conditions&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;DOB&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Email&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Password&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Last Login&lt;/th&gt;
      &lt;th style=\"border-style:solid;border-width:3px;border-color:#575757;background:#575757;\"&gt;Edit&lt;/th&gt;
  &lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;";
  $position = 1; 
  while ($results = $query-&gt;fetch()) {
  
  
      $count = count($results);
  
      echo "&lt;tr&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";            
      echo $results['id'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";
      echo $results['forename'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";
      echo $results['surname'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";
      echo $results['telephone'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";       
      echo $results['address'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";           
      echo $results['medical_conditions'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";           
      echo $results['dob'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";       
      echo $results['email'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";           
      echo $results['password'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";           
      echo $results['last_login'];
      echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";
  
      echo '&lt;input type="submit" class="btn btn-primary" value="Edit" href="editDetails.php"&gt;';
      //echo "&lt;/td&gt;&lt;td style=\"border-style:solid;border-width:1px;border-color:#D3D3D3;\"&gt;";
      } 
  }               
  
  if(isset($_POST['submit'])){
      $id = $_POST['id'];
      $forename = $_POST['forename'];
      $surname = $_POST['surname'];
      $telephone = $_POST['telephone'];
      $address = $_POST['address'];
      $medical_conditions = $_POST['medical_conditions'];
      $dob = $_POST['dob'];
      $email = $_POST['email'];
      $password = $_POST['password'];
      $last_login = $_POST['last_login'];
      if($id !=''||$forename !=''||$surname !=''||$telephone !=''||$address !=''||$medical_conditions !=''||$dob !=''||$email !=''||$password !=''||$last_login !=''){}
  
      $query = $db-&gt;prepare("INSERT INTO customer values (id, :forename, :surname, :telephone, :address, :medical_conditions, :dob, :email, :password, :last_login)");
      $dbParams = array('id'=&gt;$id, 'forename'=&gt;$forename, 'surname'=&gt;$surname, 'telephone'=&gt;$telephone, 'address'=&gt;$address, 'medical_conditions'=&gt;$medical_conditions, 'dob'=&gt;$dob, 'password'=&gt;$password, 'last_login'=&gt;$last_login);
      $query-&gt;execute($dbParams);
  
  }
  ?&gt; 
  </code></pre>