dppcyt6157 2017-05-13 09:20
浏览 36

PHP中的搜索指令不起作用

I'm trying to search a value in a specific mysql database column via PHP. However, it's not working. I tried many different ways and I had no success so far.

I'm trying the following code:

<?php

        require('connect.php');

    $search= 'search';
    $query = "SELECT * FROM `user1` WHERE `description` LIKE '%'a'%'";
    if($result){
         $smsg = $query;
    }else{
         $fmsg ="Sorry, nothing was found. Try using our menu on top left.";
    }

    ?>
  • 写回答

1条回答 默认 最新

  • douningqiu4991 2017-05-13 09:21
    关注

    Change it:

    "SELECT * FROM `user1` WHERE `description` LIKE '%'a'%'";
    

    to

    "SELECT * FROM `user1` WHERE `description` LIKE '%a%'";
    

    and try again. It will return you all the rows in which description column contains character a.

    评论

报告相同问题?

悬赏问题

  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app