Hi All,

Im accessing a function with paticular parameters, but my response is not recognising the parameter of the count value.

If I change the variable in the COUNT part of the query to a static value it works fine, but if i use the variable name it returns "undefined index".

Any help would be greatly appreciated

class answers {

    function totals($questionName, $startdate, $enddate, $advisor){
      $SQL = "SELECT COUNT($questionName) FROM interview_answers i, accounts a WHERE a.client_id = i.client_id AND advisor = '$advisor' AND sesdate>= '$startdate' AND sesdate<='$enddate'";
      $result = mysql_query($SQL);
      $row = mysql_fetch_assoc($result);
      echo $totalresponses = $row['COUNT($questionName)'];


7 Years
Discussion Span
Last Post by whiteyoh

That's a simple one. Just add the clause " AS questioncount " immediately after the COUNT keyword.
ie. SELECT COUNT($questionName) AS questioncount FROM interview_answers ... Then in line 9 use the code: echo $totalresponses = $row['questioncount'];

Edited by wilch: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.