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'
LVL 1
rgb192Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kumaranmcaConnect With a Mentor Commented:
trim function is good solution, str_replace function to resolve your problem...refer the below code

$inputdata=str_replace(' ','',$this->text);
remove your space on input string

  $this->sql = "Select * FROM orders WHERE orderid like %$inputdata";
0
 
subscriptCommented:
0
 
kumaranmcaCommented:
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%";
0
 
rgb192Author Commented:
thanks
0
 
subscriptCommented:
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;

0
All Courses

From novice to tech pro — start learning today.