php form on the fly calculated field -


wondering if can help?

i working on script allows introducing 3 fields quantity, price, discount (%), , display , store automatic calculated field (total) executing operation:

quantity * price - discount(%) = total

may me code operations in order display (not store) total?

thank in advance, pere

this code:

---dbase connect [php]if($_post["do"]=="store") { $prod_nombreproducto=$_post["prod_nombreproducto"]; $prod_cantidad=$_post["prod_cantidad"]; $prod_preciounitario=$_post["prod_preciounitario"]; $prod_descuento=$_post["prod_descuento"]; $prod_totalproducto=$_post["prod_totalproducto"];[/php]    [php]$query="insert pm_productos value('$prod_nombreproducto','$prod_cantidad', '$prod_preciounitario','$prod_descuento','$prod_totalproducto')";[/php]    quantity: <input type="text" name="prod_cantidad" size="20"> price: <input type="text" name="prod_preciounitario" size="20"> discount (%):<input type="text" name="prod_descuento" size="20"> total:<input type="text" name="prod_totalproducto" size="20"></td> </tr>[/php]  

$prod_nombreproducto=$_post["prod_nombreproducto"]; $prod_cantidad=$_post["prod_cantidad"]; $prod_preciounitario=$_post["prod_preciounitario"]; $prod_descuento=$_post["prod_descuento"]; $prod_totalproducto= ($prod_preciounitario * $prod_cantidad) - $prod_descuento; 

like that?

when you're pulling database:

$row = $db->fetch(); // select/fetch data here  $total = $row['prod_preciounitario'] * $row['prod_cantidad'] - $row['prod_descuento'];  total: <input type="text" value="<?=$total;?>"> 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -