Jump to content

perform operation on all records in table


rmelino

Recommended Posts

Hello,

 

I am having trouble writing a function in php/mysql to perform an operation on all records within my sql database.  In it's simplest form, here is what i'm trying to do:

 

my table looks like this:

 

id | name | dogs | cats | total_animals

1  | john  | 3      | 2    | 

2  | paul  | 4      | 2    | 

etc

 

On submit of a form, in I would like to update all the rows in the table above and have the 'total_animals' field filled in with the value from adding together dogs + cats for that row.

 

Thanks in advance for any help you can provide.  I'm sure this is simple but I must be missing something since I haven't had any luck with it!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.