PHP头条
热点:

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


ajaxphp数据库

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

 $.ajax({            type:"POST",            url:"getallleads.php",            data:"account="+$("#username").text(),            success:function(data){showalllead(data);}        })

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

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

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

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

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

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

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

www.phpzy.comtrue/phpyy/4306.htmlTechArticlephp-ajax从页面中获取元素传递给PHP进行数据库查询的问题 ajaxphp数据库 ajax从界面中获取id为username的文本内容“张三” $.ajax({ type:"POST", url:"getallleads.php", data:"account="+$("#username").text(), s...

相关文章

相关频道:

PHP之友评论

今天推荐