php-ajax 从页面中获取元素传递给PHP 进行数据库查询的问题

WBOY
Release: 2016-06-02 11:28:08
Original
929 people have browsed it

ajaxphp数据库

ajax从界面中获取id为username的文本内容“张三”

<code> $.ajax({            type:"POST",            url:"getallleads.php",            data:"account="+$("#username").text(),            success:function(data){showalllead(data);}        })</code>
Copy after login

PHP中接收,并查询的语句如下:

<code>  $account=$_POST["account"];  echo  "$account";  echo gettype($account);  $result = $conn->query("select * from allsalesleads where 销售人员 like '%".$account."%'");</code>
Copy after login

结果能够echo出account 内容为‘张三’ 数据类型为string 但没有查询结果

然后我直接在在如下PHP中给account赋值 张三,可以查询出。account前后的数据类型都是string

<code>  $account=$_POST["account"];  echo  "$account";  echo gettype($account);  $account='张三';echo gettype($account);  $result = $conn->query("select * from allsalesleads where 销售人员 like '%".$account."%'");</code>
Copy after login

然后我想难道前后两个account不一样吗?
然后
if ($account=="张三") 来进行判断,结果还真不一样,这是咋回事啊?

有什么解决办法吗?非常感谢!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!