Codice PHP:
<td><?php echo $row['calorie'?>        
        <input type="checkbox" value="<?php echo $row['calorie'?>" onchange="javascript:
        if (this.checked==true){
            document.getElementById('sommacalorie').value = Number(document.getElementById('sommacalorie').value) + Number(this.value);
        }else if (this.checked==false){
            document.getElementById('sommacalorie').value = Number(document.getElementById('sommacalorie').value) - Number(this.value);
        }"  />


<input id="sommacalorie" name="sommacalorie" type="text" size="10" maxlength="10" value="0" readonly />
In questa porzione di codice se metto la spunta al checkbox mi somma il valore delle calorie presenti nella pagina... e fin qui ok. Questa porzione di codice è inserita in una pag php che tramite form mi effettua la ricerca nel db. Vorrei che se effettuo più ricerche nel db il valore presente, in 'sommacalorie' alla ricerca-1 sia presente anche nella nuova ricerca così da poter sommare le calorie, di ricerca-1 e ricerca, se verrà messa la spunta nel checkbox.

Avevo pensato di fare una cosa del genere...
Codice PHP:
<?php 
        $sql
"update sum_kal set tot=tot+'".sommacalorie."'";
        
?>
Ma ".sommacalorie." non me lo riconosce...

Spero di esser stato chiaro

Grazie
dmiao83