title: Getting data from POST [id] form in PHP
body: <p>On a table that displays data from a database, I have a form that has a text area on which a user can type a receipt number and submit to save in a database for a specif row. The PHP code below is what updates the database after the form is submitted.
  I want to pick the rest of the details for the specific row so I used the <code>$_POST['id']</code> on which the receipt has been submitted. The <code>id</code> is the primary key. I'm however having a challenge since I can't fetch data from the database using <code>$id = $_POST['id'];</code>I created before outside the function The <code>update</code> statement works perfectly but the <code>SELECT STATEMENT</code>doesn't . How do I go about it? Any one?</p>
  
  <pre><code>if(isset($_POST['submit'])) {
  
  $rec = $_POST['receipt'];
  $id = $_POST['id'];
  //reate connection
  
  $sql = "UPDATE customer SET `receipt` = '".$_POST['receipt']."', `date_entered` = NOW(), `receipt_lock` = 1 WHERE `id` = '".$_POST['tid']."' AND receipt_lock = 0";
     if ($conn-&gt;query($sql) === TRUE) {
       // echo "New record created successfully";
     } else {
        echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
        exit(); 
     $conn-&gt;close();
  }
  
  
  function wall(){
  
  global $recp;
  global $id;
  
  // Create con
  
  $sql = "SELECT * FROM customer WHERE id ='$id'";
  
   $result1 = mysqli_query($conn, $sql);
          $resultarr = mysqli_fetch_assoc($result1); // fetch data
  
  
                  $name = $resultarr['name'];
                  echo "$name"; //Does not display
  
                  $amount = $resultarr['amount'];
                  $transaction_id = $resultarr['trans_id'];
                  $date = $resultarr['time_paid'];
      }
  else {
  
  echo "this is not right!;
  }
  wall();
  </code></pre>