How to search exact number in php

后端 未结 3 1649
慢半拍i
慢半拍i 2021-01-23 19:41

how to search exact number

this code is working like this

if i search 24626838(this is complete no) it is showing nothing

after that if

相关标签:
3条回答
  • 2021-01-23 20:07

    If you want to search for an exact number, use column='$number' instead of column LIKE $number. In the WHERE clause, I'd suggest to enclose even numbers in single quotes, because I recently encountered the problem that using WHERE column = 1234 this also matches 12345, but WHERE column = '1234' matches the very exact number only.

    0 讨论(0)
  • 2021-01-23 20:14

    I guess the problem is here:

    number LIKE '$str%'
    

    Don't use that way. Instead, try giving this way:

    number = '$str'
    

    So that it performs a strict SELECT instead of search. When you give a %, it might expect something else to be present (or not, I am not sure about this).

    Also, it is not a good idea to use LIKE for numbers. This is just a suggestion.

    0 讨论(0)
  • 2021-01-23 20:32

    It should work try this

     if ($x==1) $construct .= "number LIKE '".$str."%'";
    
    0 讨论(0)
提交回复
热议问题