php - how to i calculate the total sum -
as title stated;
- how calculate
total
when user checked multiple checkboxs on selected hotel?
and
- how make whenever
total
added , currenttotal
(which in mysql) exceed 500k, alert pop sayingbudget exceeded
thanks you!
code:
<?php require ("config.php"); $link = mysqli_connect($h,$u,$p,$db) or die(mysqli_error()); $query = "select bil, hotel, total, address hotels" or die(mysqli_error()); $result = mysqli_query($link,$query); echo "<table border=2>"; echo "<tr><th><b>hotel</th><th><b>total(rm)</th><th>address</th></tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr><td>$row[hotel]</td>"; echo "<td>rm $row[total]</td>"; echo "<td>$row[address]</td>"; echo "<td><a href='delete.php?del=$row[bil] '>delete</a></td>"; echo "<td><input name='checkbox[]' type='checkbox' value='{$row['hotel']}'></td></tr>" ; } ?>
use javascript or jquery (js library).
whenever checkbox selected/deselected, retrieve value corresponding 'total' cell
$selected_val = $(this).parent.(".total").text //sample in jquery,
and remove 'rm' word. +/- value in total.
Comments
Post a Comment