I'd like to get some help how to manage to make the function display every input value i'm clicking instead of always displaying the first data.
If i click on the edit icon for the second record data:
The results displays only the first data record as showen below:
cart.php
<?php
$query1 = "SELECT * FROM cart where user_id=".$_SESSION["id"]." ";
$run_query1 = mysqli_query($conn,$query1) or die(mysqli_error($conn));
while($row = mysqli_fetch_array($run_query1)) {
$totalprod=$row['product_price']*$row['qty'];
echo'
<tr>
<td class="thumbnail-img">
<a href="#">
<img class="img-fluid" src="data:image/jpeg;base64,'.$row['product_image'].'" alt="" />
</a>
</td>
<td class="name-pr">
<a href="#">
'.$row['product_name'].'
</a>
</td>
<td class="price-pr">
<p><b>'.$row['product_price'].'DT</b></p>
</td>
<td class="quantity-box"><input type="number" size="4" value="'.$row['qty'].'" min="1" class="qty"></td>
<td class="total-pr">
<p><b>'.$totalprod.'DT</b></p>
</td>
<td class="remove-pr">
<a class="update" href="#" update_id="'.$row['product_id'].'" >
<i class="fas fa-edit"></i>
<a href="cart.php?deleteId='.$row['product_id'].'" >
<i class="fas fa-trash-alt"></i>
</td>
</tr>
';
}
action.js
$(document).ready(function(){
$("body").delegate(".update","click",function(event){
var update = $(this).parent().parent().parent();
var update_id = update.find(".update").attr("update_id");
var qty = update.find(".qty").val();
$.ajax({
url : "cart.php",
method : "POST",
data : {updateCartItem:1,update_id:update_id,qty:qty},
success : function(data){
alert(qty);
}
})
})
})
question from:
https://stackoverflow.com/questions/65889909/ajax-call-result-is-only-displaying-the-first-table-sql-record 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…