hello there,

i'm currently studying php and i have no idea about some codes
im trying to learn how to compute a total amount that i called from a database

its like this i call this data from a database using SELECT * FROM

Item Price
book 5.00
pencil 3.00

how can i compute the total price?
i tried searching but i get trouble understanding some scripts
can you please specify what a certain code can do so i can understand it easily
(sorry for my bad english >_<)

thanks!

SELECT * FROM SUM(Price) FROM table_name;

The above SQL is wrong.

The correct statement would be:

SELECT SUM(Price) Total FROM table_name

This aliases the result of SUM(Price) to the column Total for easier reference.
More info on aliasing columns: http://dev.mysql.com/doc/refman/5.0/en/select.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.