Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP fails Updating existing records
    primarykey
    data
    text
    <p>I have the following PHP Code :</p> <pre><code>//Selecting amount from rcpts_exp table $query = "SELECT amount from rcpts_exp"; $result = mysql_query($query); if(!$result){ echo "FAILED"; } $num = mysql_num_rows($result); //fetching each row for($i=0;$i&lt;$num;$i++){ $row = mysql_fetch_assoc($result); //Simple Mathematics $a_b_t = $row['amount'] / 1.16; $t = $a_b_t * 0.16; //--------------------------------For Testing Output //echo $row['amount']."&lt;br /&gt;"; //echo "ABT = ". $a_b_t = number_format($a_b_t,2)."&lt;br /&gt;"; //echo "tax = ".$t = number_format($t,2)."&lt;br /&gt;"; //-------------------------------End Testing //Update the values into rcpts_exp for each amount $query2 = "UPDATE rcpts_exp SET amount_before_tax = '".$a_b_t."', tax = '".$t."' WHERE amount = '".$row['amount']."'"; $result2 = mysql_query($query2); if(!$result2){ echo "Update Failed"; mysqli_error(); } } </code></pre> <p>The "testing" part outputs the result needed perfectly, it divides the <code>$row['amount']</code> by 1.16 and the next one multiplies by 0.16. So considering the output the correct, the problem goes towards the UPDATE section.- it might either updates the <code>amount_before_tax</code> and <code>tax</code> columns as <code>0.00</code> or skipping as default value as defined in mysql.</p> <p>The Structure of my table is as follows :</p> <ul> <li>id - int(11) AI </li> <li>amount - float(10,2)</li> <li>amount_before_tax - float(10,2)</li> <li>tax - float(10,2)</li> </ul> <p>Please Help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload