Site icon Hip-Hop Website Design and Development

How one can get every row worth from the desk utilizing the id of the tbody [closed]

-3

I have been working for inventory out stock course of which might search all merchandise within the search bar and show within the table1 and click on the merchandise chosen to enter the amount wish to deduct.

And show every information in desk row to table2 chosen by the consumer.

Anybody will help me with this? i simply wanna know on how one can get the every worth in table2 to save lots of within the database with title "tblstockout" and replace these merchandise amount in "tblstock"

Thanks and regards

this is my code:

<!--- html code to show the table1 and desk 2-->
<!DOCTYPE html>
<html>
<head>
 
<physique class="hold-transition sidebar-mini layout-fixed">
       <!--TABLE 1-->
      <div class="input-group"><div class="input-group-prepend"><span class="input-group-text" id="basic-addon1"><i class="fas fa-search"></i></span></div>
          <enter class="form-control" sort="text" placeholder="Product Search" aria-label="Search" id="search" title="search" onkeyup="loadproducts();"/>
        </div></div>
      <div id="product_area" class="table-responsive-sm table-wrapper-scroll-y my-custom-scrollbar" >
        <desk class="table table-bordered table-striped" model="cursor: pointer;" id="table1">
          <thead>
            <tr class='text-center'>
              <td>Merchandise Code</td>
              <td>Merchandise description</td>
              <td>Unit</td>
              <td>Shares</td>
            </tr>
            <tbody id="products">
            </tbody>
          </thead>
        </desk>
      </div>
    </div>
    <!--TABLE 2-->
    <div id="content">
      <div id="price_column" class="table-responsive-sm table-wrapper-scroll-y my-custom-scrollbar-a">
        <kind technique="POST" motion="">
        <desk class="table table-bordered table-striped" model="cursor: pointer;" id="table2">
          <thead>
            <tr class='text-center'>
              <td>Merchandise Code</td>
              <td>Merchandise description</td>
              <td>Unit</td>
              <td>Amount</td>
              <td>Motion</td>
            </tr>
          </thead>
          <tbody id="tableData">
          </tbody>
        </desk>
        </kind>
      </div>
    </div>
  
        
  <!--Button to submit-->      
        <button model="float: left;" id="buttons" sort="button" title='enter' class="Enter btn btn-secondary border"><i class="fas fa-handshake"></i> End</button>
   <!--Button to cancel-->         
        <button model="float: left;" id="buttons" sort="button" class="cancel btn btn-secondary border"><i class="fas fa-ban"></i> Cancel</button>
      </div>
  

 </div>
  </div>
<!--JQuery to show information search by the user-->
  <?php embody('templates/js_popper.php');?>
  <!--script function-->
  <script sort="text/javascript" src="script.js"></script>
</physique>
</html> 

<!----PHP code for the item_load.php to fetch product within the database-->

<?php
//database included//

    if (isset($_POST['products'])){

        $title = mysqli_real_escape_string($con,$_POST['products']);
        $present   = "SELECT * FROM tblstock WHERE item_desc LIKE '$name%' AND qnty > 0 OR id LIKE '$name%' AND qnty > 0";
        $question  = mysqli_query($con,$present);
        if(mysqli_num_rows($question)>0){
            whereas($row = mysqli_fetch_array($question)){
                echo "<tr class='js-add' data-barcode=".$row['id']." data-product=".$row['item_desc']." data-unit=".$row['unit'].">
                <td><middle>".$row['id']."</td>
                <td>".$row['item_desc']."</td>";
                echo "<td><center>".$row['unit']."</center></td>";
                echo "<td><center>".$row['qnty']."</center></td>";
            }
        }
        else{
            echo "<td></td><td><center>No item found!</center></td><td></td><td></td>";
        }
    }?>
<script>
perform loadproducts(){
    var title = $("#search").val();
    if(title){
        $.ajax({
            sort: 'put up',
            information: {
                merchandise:title,
            },
            url: 'item_load.php',
            success: perform (Response){
                $('#merchandise').html(Response);
            }
        });
    }
};

//The script perform to place amount of every item_desc chosen and add one other row to the table2//

$('physique').on('click on','.js-add',perform(){
        var goal = $(this);
        var product = goal.attr('data-product');
        var barcode = goal.attr('data-barcode');
        var unit = goal.attr('data-unit');    
        swal({
        title: "Enter Quantity:",
            content material: "input",
          })
          .then((worth) => {
              if (worth == "") {
                  swal("Error","Entered none!","error");
              }else{
                  var qtynum = worth;
                  if (isNaN(qtynum)){
                    swal("Error","Please enter a valid number!","error");
          }else if(qtynum == null){
            swal("Error","Please enter a number!","error");
              }else{
    
                    $('#tableData').append("<tr class='prd'><td class='barcode text-center'>"+barcode+"</td><td class='text-center'>"+product+"</td><td class='text-center'>"+unit+"</td><td class='qty text-center'>"+worth+"</td><td class='text-center p-1'><button class='btn btn-danger btn-sm' type='button' id='delete-row'><i class='fas fa-times-circle'></i></button><tr>");
    
        }
            }
  });
});
</script>