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;


php mysql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Country State City Dropdown list in PHP MySQL PHP

Country state city dropdown using ajax in php. You'll learn how to populate country city state dropdown based on previous selection in php using ajax

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

Ajax Live Data Search using jQuery PHP MySQL

ajax php live search with mysql database example. Here you will learn how to implement ajax live data search using php mysql database with example

Category Subcategory Dropdown in PHP MySQL Ajax

PHP mysql dynamic dropdown list onchange. Here, we'll show how to populate category and subcategory in dropdown list using ajax in PHP mysql

PHP Code for Update Data in MySQL Database - Tuts Make

PHP code for updating data in mysql database. Here we'll show you how to fetch and update form data into mysql database using PHP code. &demo