At a loss here... trying to sort database records using a drop down list but get an error message saying

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '2012'' at line 1

So... I want the user to be able to sort the database records according to class year.


include "xxx.php";

$sql = "SELECT * FROM players";

if (isset ($_POST['search'])) {  

$search_term = mysql_real_escape_string($_POST['class_filter']);

$sql .= "WHERE class_filter = '{$search_term}'";

$query = mysql_query($sql) or die(mysql_error());

do I need to use something other than just calling the search_term?