Problem in a Dynamic Web Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zeedzkanik
Forum Newbie
Posts: 1
Joined: Tue Sep 28, 2010 12:18 am

Problem in a Dynamic Web Form

Post 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
.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Problem in a Dynamic Web Form

Post 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.
Post Reply