Math in PHP

Hi All,
Been trawling the net looking for answers to what seems a easy thing to do.

I have a database, with one table. With 5 rows. 2 of these rows have numbers in, i want to add 1 to them and then add them together.

Hope someone can help.

KingDing

this will increase column with 1,
[sql]
UPDATE database SET column = column + 1;
[/sql]

you can get sum with this
[sql]
SELECT SUM(column) FROM database
[/sql]

I have tried that. :frowning:

I have a form with 3 fields, username, name and cost

Every time somebody fills out a form i want cost to add to past cost and save to a separate cell. If that makes sense.

I was struggling with something similar to this about a week ago. If you’re super n00b in PHP, then when people give you SQL code, you might think you can just put that in your document. But that’s not so. Languages that interact with SQL do so with their own “dialect” of SQL. I think that’s what his problem is. I’m not good enough to tell him what he needs to use, but if someone else understands what I’m saying, maybe you could help him now.

Hi,

Do you want to add cost of all data in one when update a record if so than have to store it in one variable and than run update query

$count =select count(cost) from tablename;
than $count = $count +1;

update query.

Hope this is what you want

Sponsor our Newsletter | Privacy Policy | Terms of Service