mysql - PHP function calling sql SUM not working -


don't know why function not working

     function sumall($row ,$monthnr, $first){       $data = "select sum($row) closeday month(dates) = $monthnr , year(dates) = year(curdate())";       $result = mysql_query($data);       $query_data = mysql_fetch_row($result);       $first = $query_data[0];       return $first;     }   //calling function sumall('total' , 01, $first); 

help please thanks

you have non sence parameters in function, try this:

   function sumall($row,$monthnr){   $data = "select sum(".$row.") sums closeday month(dates) = '".$monthnr."' , year(dates) = year(curdate())";   $result = mysql_query($data);   $query_data = mysql_fetch_array($result);   $first = $query_data['sums'];   return $first; } 

call that:

 sumall('total' , 01); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -