the following question relates to a high school reporting system.
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE report_data_04_2 SET sci1=%s, sci2=%s, sci3=%s, sci4=%s, sci_effort=%s, sci_attitude=%s, sci_homework=%s, sci_org=%s WHERE id=%s",
GetSQLValueString($_POST['Sci1'], "text"),
GetSQLValueString($_POST['Sci2'], "text"),
GetSQLValueString($_POST['Sci3'], "text"),
GetSQLValueString($_POST['Sci4'], "text"),
GetSQLValueString($_POST['Sci6'], "text"),
GetSQLValueString($_POST['Sci7'], "text"),
GetSQLValueString($_POST['Sci8'], "text"),
GetSQLValueString($_POST['Sci9'], "text"),
GetSQLValueString($_POST['id'], "int"));
In my update statement, I have hard coded the mysql field names that are the destinations for all of the form data passed by form1.
In this eg Sci menas science. However, each subject has its own 3 letter code, and the field names of the db all use this code to reflect the difference in subjects.
What I need is the following situation
When a teacher logs in to make comments on Science work, the data should be saved to fields beginning with sci. If they want to make comment on English work, then the data will be saved to fields beginning with eng.
I can get as far as declaringa variable ($tlc) which contains the correct 3 letter code, but how do I use this in my UPDATE statement to SET the corresponding fields with the appropriat data?
I have tried, but am at the limit of my knowledge. Can anyone help me?