Home > Backend Development > PHP Tutorial > Mysql模糊查询去除空格有关问题?

Mysql模糊查询去除空格有关问题?

WBOY
Release: 2016-06-13 10:27:51
Original
1819 people have browsed it

Mysql模糊查询去除空格问题??
$sql = "SELECT mingc FROM info WHERE 1=1";

模糊判断
if($mingc != ""){
  $sql.="AND mingc like '%$mingc%' ";
}

如何在名称文本框模糊查询时 去掉空格》》可以用trim($mingc)

但问题是==》 先打一个空格在输入模糊条件/ 或者相反
 
【 即同时去除左右空格,且可进行模糊查询】

等待.......

------解决方案--------------------
trim()本来就是去除左右空格啊,......今天怎么了?
------解决方案--------------------
if(!empty($mingc)){
$sql.="AND mingc like '%trim($mingc)%' ";
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template