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!
I'm building an online ordering system for a project at Uni, What I'm attempting to do is calcualte a figure based on the quantity and price. At the moment the user selects from a series of radio buttons which then uses the value to lookup in another table the item description and then inserts that details along with other user entry such as the quantity into an order table. The item table does contain a value for price.
What my question is how would i go by calculating the two togeother and then inserting that value into the order table along with the other details which are currently being passed.
Would a function need to be implemented or something else?
select the price from the item table, multiple the price by quanitity passed, store the results in the order table.
I'd suggest storing an item id, order id (since multiple items can be in an order), and quantity requested as a row in the order table. Perform a quick check against available inventory to make sure the quantity is valid. When the user reaches a checkout page, you can total the items in their order together by simple multiplying the quantity and item price (found through a join query). A seperate table links the user to the order.
I was wondering how i would multiply the two togeother. I'm quite new to PHP so have limited experince.
If you could give me a starting hand that would be great
Would i have to place the values into a variable and then times the two togorther?
the way in which i think i will do this task is by querying the table for the price based on the user input. I will obtain the quantity from the user input which will be posted from the input form. the basic code is as follows:
$totalprice = $quantity * $attribute
the $attribute will be from the query reults fro the price and the $quantity will be taken from the user input and then the post function.
$totalprice will then be inserted into the orders table.