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.
Problem in a Dynamic Web Form
Moderator: General Moderators
-
zeedzkanik
- Forum Newbie
- Posts: 1
- Joined: Tue Sep 28, 2010 12:18 am
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Problem in a Dynamic Web Form
Look up the price of the item they chose in the database, and multiply that by the value they put into the quantity box.
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.
Code: Select all
// get price from database
$total = intval($_POST['quantity']) * $price;
echo $total;