Skip to content
Advertisement

How to get sum of weight as total_weight from one table and store it in another table

I had two similar fields namely total_weight that is in my phyto table and weight that is in my phyto_species table shown below

CreatePhytosTable

CreatePhytoSpeciesTable

I have been trying to sum weight using array_sum() as total weight and then assign it to ‘total_weight’ => $totalweight] shown below however when I save the error says Undefined variable: totalweight. I would like to request for assistance please

Advertisement

Answer

declare the variable

before you call it. Your code should be something like:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement