I need your help.
I have a PHP code that I use to query a MySQL database after selecting a certain operator. The operators that I have from the dropdown list are "LESS THAN, GREATER THAN, and EQUALS". The problem I have is; whichever operator I select, the result that I get from the database is always for the "LESS THAN" operator. That is, it give me the same result whether I select "LESS THAN", "GREATER THAN" or "EQUALS". I tried to locate the problem but failed. Here is the code that I use:
if ($op='LESS THAN') {
$query = "SELECT * FROM tbl_reservoir WHERE res_vol < '$vol'";
} elseif ($op='GREATER THAN') {
$query = "SELECT * FROM tbl_reservoir WHERE res_vol > '$vol'";
} elseif ($op='EQUAL') {
$query = "SELECT * FROM tbl_reservoir WHERE res_vol = '$vol'";
}
$op is a variable that holds the operator, and "res_vol" is a field that I compare with from the database table.
if ($op == 'EQUAL')line. You know if you reach that, then neither of the previous two options was chosen. I tend to make that option anelse- I think it makes the code a little more readable.