Показать сообщение отдельно
  #1 (permalink)  
Старый 26.02.2022, 19:57
Новичок на форуме
Отправить личное сообщение для Asta Посмотреть профиль Найти все сообщения от Asta
 
Регистрация: 26.02.2022
Сообщений: 2

Помогите найти общую сумму корзины при нажате плюс минус
это корзина
<main>
<table class="shopping_list">
<tr>
            <th>Image</th>
            <th>Name</th>
            <th>Price</th>
            <th>Quantity</th>
            <th>Total</th>
            <th>Action</th>
</tr>

<?php 

  $total = 0;  
 
    include "basket/connect.php";
    $sql = "SELECT * FROM `basket` ";
    $result = mysqli_query($con, $sql);
    if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)){ 

?>
 <tr>
  <td><img src=img/<?php echo $row['image_url'];?>> </td>
  <td><?php echo $row['name'];?>  </td>
  <td>$ <?php echo $row["price"];?></td>
  <td>
<button class="minus" type="button" style="width:17%;">
<i class="fa fa-minus"></i></button>
<input class="quantity" type="text" value='<?php echo $row["quantity"]; ?>' style="width:17%;"/>
<button class="plus" type="button" style="width:17%;"><i class="fa fa-plus"></i></button>
</td>
  
 <td><span class="count_price" data-price="<?php echo $row["price"]; ?>">$ <?php echo $row["price"]; ?>  </span></td>

  <td> <form method="POST" action='basket/delete.php ?id=<?php echo $row["id"] ?> '>
       <input type="submit" name="delete" value="Remove">
  </form></td>
<?php

$total = $total +  $row["price"];
?>
</tr>
<?php
}
  }

 ?>
 <tr>
<td colspan="4" align="right">Total</td>
<td> $ <?php echo number_format($total,2); ?></td>
<td></td>
</tr>
</table>
Ответить с цитированием