If I have a value of 1+ in a VARCHAR column in a MySQL table, how can I compare this variable in php?
if ($days=="1+")
does not appear to work, so how to compare it including the plus sign?
If I have a value of 1+ in a VARCHAR column in a MySQL table, how can I compare this variable in php?
if ($days=="1+")
does not appear to work, so how to compare it including the plus sign?
If in your database if you days column as varchar, than you will get the exact value (even with +), so:
if($days == "1+") is true
a more complete code for you to try
$res = mysql_query("SELECT days FROM table");
while( $row = mysql_fetch_assoc($res) ) {
if($row["days"] == "1+") echo 'found' . '<br>';
}
Can you show us your query? I have a feeling that you've misidentified the issue.
That said, have you tried typecasting?
if ((string) $days == "1+")