Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

strip spaces

     case 'searchbyorderid':
        $this->sql = "FROM orders WHERE orderid like '%$this->text%'";
        break;


want to strip ' '
from
$this->text


so if a person searches for orderid
' 700 '
they will get
'700'
Avatar of subscript
subscript

Hi Rgb,

You are search the value of  "Order id". I think order is number datatype.. no need add ' ' of your query...

Refer the below query...its helpful for you

  $this->sql = "Select * FROM orders WHERE orderid like %$this->text%";
ASKER CERTIFIED SOLUTION
Avatar of kumaranmca
kumaranmca

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks
The accepted solution works okay unless you search on multiple words (a phrase).

For multiple words -- you need spaces between them, which is why I still believe trim function is the better solution.

        $inputdata = trim($this->text);

        $this->sql = "FROM orders WHERE orderid like '%$inputdata%'";
        break;