0

I'm having a little trouble writing an if statement to update a couple of database fields based on matching a student ID between 2 tables. This is a form where I pass the initial Student and Class IDs to the SQL statement (this works just fine, but when I try to add the IF statement layer, I keep getting a T_CLASS parse error.

IF class.s1i=$SID THEN $sql="update students, class SET students.currentStatus='confirmed',students.timeStamp='$dateLastUpdated', class.s1s='confirmed' where students.SID=$SID";
ELSEIF class.s2i=$SID THEN $sql="update students, class SET students.currentStatus='confirmed',students.timeStamp='$dateLastUpdated', class.s2s='confirmed' where students.SID=$SID";
ELSE echo "no match";
END IF;

Can anyone tell me what I'm missing? I've tried separating these out with parens but this didn't make a difference.

Thanks!

Edited by httpgal: spaces

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by pritaeas
0

You cannot reference mysql table columns in a php if statement.

Php if structure looks like this:

if ($var1 == $SID) 
{
  $sql = "";
}
elseif ($var2 == $SID)
{
  $sql = "";
}
else 
{
  echo 'no match';
}

Edited by pritaeas: n/a

This topic has been dead for over six months. 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.