PHP/PDO:SQl查找包含字符串值的行 [英] PHP / PDO : SQl to find row which contains a string value

查看:69
本文介绍了PHP/PDO:SQl查找包含字符串值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试请求查找包含特定String值的行.

I try to make a request to find rows which contains a specific String value.

这是我的代码的一部分:

Here is an extract of my code :

// Getting motscles value
        $motscles = $_POST['motscles'];

        // Prepare a second SQL request to get all annonces posted by the user
        $result2=$connexion->prepare("select * from annonces where titre LIKE = '%".$motscles."%' ");

我没有结果,我认为我的要求不好..

I have no result, and i think my request is bad ..

推荐答案

LIKE =

那是不正确的,应该是-

Thats not correct, it should be -

LIKE  '%".$motscles."%'

在此处检查类似通配符的用法

Check here the like wild-card usage

http://dev.mysql. com/doc/refman/5.0/zh-CN/string-comparison-functions.html#operator_like

这篇关于PHP/PDO:SQl查找包含字符串值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆