php - how to i calculate the total sum -


as title stated;

  1. how calculate total when user checked multiple checkboxs on selected hotel?

and

  1. how make whenever total added , current total (which in mysql) exceed 500k, alert pop saying budget 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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -