i have a piece of code that finds the sum of the credits of the courses that were chosen in the multiple drop down list. my code works fine when there is a value that was selected and i can easily assign the variable to the session variable. however i an having some problems when there was nothing that was selected from the multiple select drop down list. when nothing is selected the session variable is still storing the previous value when i want it to be storing zero
here is my code below
$q="SELECT sum(credits) FROM courses WHERE course_code='$val'";
if ($result2=mysql_query($q))
$count2= mysql_num_rows($result2);
$row = mysql_fetch_row($result2);
$first=$row[0];
echo $first;
print_r($count2);
$sum= $sum+$first;
echo "$count2";
//$sum=0;
$_SESSION['credit_total'] = $sum;
i tried UN setting the session variable but i was also having some trouble doing that since the $sum variable is just blank when nothing is selected. can some offer some assistance on how i can achieve this
thanks