Reputation: 161
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?
Upvotes: 1
Views: 249
Reputation: 91
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+")
Upvotes: 0
Reputation: 67
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>';
}
Upvotes: 1