Page 1 of 1

Problem in a Dynamic Web Form

Posted: Tue Sep 28, 2010 12:35 am
by zeedzkanik
Dear Friends,
I am bit fresh for PHP and i want to know how to display the total price by multiplying quantity and the unit price when the user selects the product type from a drop down list.
(Simply there is a drop down box and user select the product type from it and input the quantity.Then within same form the total price should be displayed.)

This is a web based and database driven system.The required information are taken from the relevant tables.
I think that i explained my question clearly and it will be great help for me if u all can help me to fix this.Thanx a lot.
Regards,
Zeedz
.

Re: Problem in a Dynamic Web Form

Posted: Tue Sep 28, 2010 11:40 am
by Jonah Bron
Look up the price of the item they chose in the database, and multiply that by the value they put into the quantity box.

Code: Select all

// get price from database
$total = intval($_POST['quantity']) * $price;
echo $total;
This assumes that the form uses method POST and that the quantity box is called "quantity". intval() cleans the value of $_POST['quantity'] to make sure it's in integer form.