i m having some trouble trying to find the sum of an queried variable however this variable is inside a loop and it is not summing it is just returning the value at that instant in time this is the code below
@$code= $_POST['coursecode_1'];
if( is_array($code))
{
//$sum= array();
while (list ($key, $val) = each ($code))
{
//echo "$val "; //val contains the course code
$q="SELECT sum(credits) FROM courses WHERE course_code='$val'";
if ($result_2=mysql_query($q))
echo '<p>nice1</p>';
else
echo 'good shit';
$row = mysql_fetch_row($result_2);
echo "$row[0");
}
}
when i select 2 courses i just get the credits of each course separately