Hello,
I have a script that I would like to use to add up values from a drop-down list and come up with a total, which would then be added to a database. I'm stuck on the first part: getting the values to add up using POST and a session variable. The drop down displays properly but each time the form is submitted the value for the total stays at "0." Any help is very much appreciated.
<?php session_start();
if(isset($SESSION['caltotal'])){
$select = $POST['Select'];
$SESSION['caltotal'] += $select;
}
else {
$SESSION['caltotal'] = 0;
}
?>
<html>
<head>
<title>Daily Calories Consumed</title>
</head>
<body>
<form>
<?php
$foodarray = file('foodlist2.txt');
echo "<select name=\"Select\" id=\"calselect\">";
for($j=0;$j<count($foodarray);$j++) {
$fvalues = explode("|", $foodarray[$j]);
echo "<option value=\"$fvalues[0]\"> $fvalues[1] </option>";
}
echo "</select>";
echo "<h1>Daily Calories Total: " .$_SESSION['caltotal']." </h1>"
?>
<input type="submit" name="Submit" value="Add Selected Food">
</form>
</body>
</html>