rgb192
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'
$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'
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%";
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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;
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;
http://us2.php.net/manual/en/function.trim.php