Passing input value to mysql queries

Viewed 38

I want to take the value (id) from the input box in order to run the mysql queries and make the value as variable. Below is my html code.

<input type="text" name="staff_id2" id="staff_id2" />

The input box working fine and store the value which is retrieve from the server side.

Below is the js code, in order to retrieve the data from the server side.

$(document).on('click', '.withdraw', function(){

         $('#withdrawModal').modal('show');
         var user_id = $(this).attr("idu");
         var branch = $(this).attr("branch");
         
         $.ajax({
          url: "fetch_withdraw.php",
          method: "POST",
          data: {
            user_id: user_id
          },
          dataType: "json",
          success: function(data) {
        
            $('#staff_id2').val(user_id);
            $('#asset_branch').val(branch);
          }
        })
      });

Below the code from the server side:

$sub_array[] = '<button type="button" name="withdraw" branch="'.$row["branch"].'" idu="'.$row["id"].'" class="btn btn-danger btn-xs withdraw">Withdraw</button>';

My question is how to take the value from the input box (staff_id2) and make it as a variable in order to run the sql queries?

Any help would be greatly appreciated.

0 Answers
Related