Hi Guy's,
Many thaks for your replies. Looking at using the Information Schema's "columns" was following incorrect advice. That aside I have found out that I can use a variable as a column name which I now have working.
The issue I now have is this; if I run the following query:
mysql_select_db($database_navex, $navex);
$query_Questions = sprintf("SELECT AirlineName, ".$Question." FROM CrewFlightFeedBackAnswers ORDER BY AirlineName");
$Questions = mysql_query($query_Questions, $navex) or die(mysql_error());
The result is a list of the "AirlineName" and the content of the variable colmun "$Question".
The I need to SUM the content of al the results from "$Question" for each "AirlineName". Something like:
while($row_Questions = mysql_fetch_assoc($Questions)) {
mysql_select_db($database_navex, $navex);
$query_Answers = sprintf("SELECT AirlineName, SUM(".$Question.") AS A FROM CrewFlightFeedBackAnswers");
$Answers = mysql_query($query_Answers, $navex) or die(mysql_error());
$row_Answers = mysql_fetch_assoc($Answers);
$totalRows_Answers = mysql_num_rows($Answers);
print $row_Answers['AirlineName']. " " . $row_Answers['A'];
}
Or am I again looking at this completely wrong.
I then need to SUM the content of $Question for each record and produce a list of AirlineNames with the resulting SUM.