add the value of a variable returned in a while loop [closed]

Try to change with this:

    ........
    ........
    ........


    $fullcost = 0;
    while( $connected->have_posts() ) : $connected->the_post();

        $cost = get_post_meta( $post->ID, 'foxware-ingredient-cost', true );
        $fullcost += $cost;
        echo '<li>';

        the_title();

        // Display cost
        echo '<br>';
         echo 'Cost: ' . $cost;
        echo '</li>';
    endwhile;

    echo $fullcost; ?>

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş