PHP - How to directly update after submit

PHP - How to directly update after submit

Good day, I have a problem and this is all about transferring values after I submit and search the data into textbox.

Good day, I have a problem and this is all about transferring values after I submit and search the data into textbox.

Problem - The value is not being sent after i submit, what I need to do is to submit it again for it to send or read the value.

Expected Output - how can I send or update that value to another column on different table in just one submit to the button?

Here is my code, the logic of it was to search the LIKE values and after i click the button it will then display it. but will not update or send it directly.

  <form method="POST">
 <!--THE INPUT THAT DISPLAY THE QR CODE VALUE -->
                <textarea class="form-control text-center" id="scanned-QR" name="id"></textarea><br>

            &lt;!--THE BUTTON THAT WILL SUBMIT THE VALUE TO DETERMINE THE VALUE OF THE TEXTBOX--&gt;

             &lt;input type="submit" name="search" value="Top-up" class="btn btn-primary"&gt;&lt;/input&gt;

</form>

then my connection query to execute the button

 <?php 

//CONNECTION      
$connection =mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,'inflightapp');

//END CONNECTION

//SUBMIT THE INPUT AND SEARCH THE LIKE VALUE
if (isset($_POST['search'])) {
  $txtCode = $_POST['id'];
  //GET THE INPUT BELOW AMOUNT

          //REMOVE THE SPECIAL CHARACTER QR CODE: | TO READ AND SEARCH FOR SIMILAR VALUE 
          $hashCase =  $txtCode;
          $str = ltrim( strstr($hashCase,":"),":");
          $strFinalString = trim(substr($str,0,strpos($str, "|")));
          //END OF REMOVING SPECIAL CHAR


  //QUERY TO SEARCH THE VALUE
  $query = "SELECT * FROM scratch_cards WHERE code LIKE '%$strFinalString%' ";
  $query_run = mysqli_query($connection,$query);
  //END

  //FETCH THE DATA INTO MY DATABASE 'scratch_cards'
  while($row = mysqli_fetch_array($query_run))
  {
    $amount = $row['amount'];

    ?&gt;
    &lt;form action="" method="POST"&gt;
      &lt;input type="hidden" name="id" value="&lt;?php echo $row['id'] ?&gt;"&gt;&lt;/input&gt;
      &lt;input type="text" name="amount" value="&lt;?php echo $row['amount'] ?&gt;"&gt;&lt;/input&gt;

    &lt;/form&gt;
    &lt;?php
  }
  //END OF FETCHING DATA


}

//END OF THE SUBMIT

 ?&gt;


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

PhP MySQL Projects

Simpliv LLC, a platform for learning and teaching online courses. We basically focus on online learning which helps to learn business concepts, software technology to develop personal and professional goals through video library by recognized industry experts and trainers.

The Complete PHP MySQL Professional Course with 5 Projects

The Complete PHP MySQL Professional Course with 5 Projects

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!