佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

楼主: 悍马

php LIKE 和 EQUAL 不能共用?

[复制链接]
发表于 15-8-2019 06:14 PM | 显示全部楼层
WeChat Screenshot_20190815181403.png
代码跑通~~XD

评分

参与人数 1人气 +5 收起 理由
悍马 + 5

查看全部评分

回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 15-8-2019 06:15 PM | 显示全部楼层
可以了
回复

使用道具 举报

 楼主| 发表于 15-8-2019 06:16 PM | 显示全部楼层
谢谢你,来槟城记得联络我噢
回复

使用道具 举报

 楼主| 发表于 15-8-2019 06:34 PM | 显示全部楼层
真的真的好开心
回复

使用道具 举报

发表于 15-8-2019 06:50 PM | 显示全部楼层

能帮到你,我也很开心~~
回复

使用道具 举报

发表于 15-8-2019 06:51 PM | 显示全部楼层
悍马 发表于 15-8-2019 06:16 PM
谢谢你,来槟城记得联络我噢

不客气,有机会我会上去的(不知道何年何月)。
回复

使用道具 举报

Follow Us
 楼主| 发表于 22-8-2019 06:47 PM | 显示全部楼层
slaythia 发表于 15-8-2019 06:51 PM
不客气,有机会我会上去的(不知道何年何月)。

你好@slaythia
回复

使用道具 举报

 楼主| 发表于 22-8-2019 06:50 PM | 显示全部楼层
我刚刚去看php error log, 发现每次execute你的code就出现这行error,

PHP Notice:  Undefined index: status in C:\MAMP\htdocs\3g\index2.php on line 109

line 109 就是这行码 :

$status = $_POST['status'];

你看如何?
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 23-8-2019 11:48 AM | 显示全部楼层
对不起,是我的错。删除掉line99就没事了, 多余的码.
回复

使用道具 举报

发表于 27-8-2019 09:31 AM | 显示全部楼层
抱歉,现在才上Cari,最近比较忙。
回复

使用道具 举报

 楼主| 发表于 27-8-2019 09:57 PM | 显示全部楼层
@slaythia, 我要再次感谢你,你解决了那个瓶颈之后,我可以google很多问题自己解决了。现在我终于可以实现渴望很久自己的database了。我的database beta version已经正在被试用了,虽然还有很大的改进空间,但是已经满足目前我们公司的要求了。
回复

使用道具 举报

 楼主| 发表于 27-8-2019 10:03 PM | 显示全部楼层
可是我可以问你,为何你要
$input = $_POST;


$table_name = 'tbl_name';


$column = '*';

直接用$_POST, $tbl_name和*不能吗?
回复

使用道具 举报

发表于 29-8-2019 10:40 AM | 显示全部楼层
悍马 发表于 27-8-2019 10:03 PM
可是我可以问你,为何你要
$input = $_POST;


$table_name = 'tbl_name';


$column = '*';

直接用$_POST, $tbl_name和*不能吗?

个人写程序的习惯,为了代码的可读性。
回复

使用道具 举报

发表于 29-8-2019 10:53 AM | 显示全部楼层
悍马 发表于 27-8-2019 10:03 PM
可是我可以问你,为何你要
$input = $_POST;


$table_name = 'tbl_name';


$column = '*';

直接用$_POST, $tbl_name和*不能吗?

还有一点,直接使用$_POST,严格来说会有安全隐患(SQL注入)。

【PHP官网】SQL 注入: https://www.php.net/manual/zh/security.database.sql-injection.php
回复

使用道具 举报

 楼主| 发表于 29-8-2019 07:16 PM | 显示全部楼层
喔原来。迟一些我会学Prepared Statement
回复

使用道具 举报

 楼主| 发表于 29-8-2019 07:20 PM | 显示全部楼层
我可以问你最后一个问题吗?就是我希望可以query数字 below max_price, 可是结果不是应该的结果


if (!empty($input['status']))

{
{
    if ($input['status'] == "SALE");
    {

    if (is_null($where))
    {
            $where = "WHERE";
    }
    else {
            $where = "AND";
    }

$query .= " $where status LIKE '%".$input['status']."%' AND `selling` <=
{$input['max_price']}";
    }
}
{

    if ($input['status'] == "LET");
    {

    if (is_null($where))
    {
            $where = "WHERE";
    }
    else {
            $where = "AND";
    }

$query .= " $where status LIKE '%".$input['status']."%' AND `rental` <=
{$input['max_price']}";
    }
}   

}
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 29-8-2019 07:22 PM | 显示全部楼层
回来的结果很奇怪,很多数据都没有呈现。比如  the value with "0" in SALE or LET not called. (The default value for not for sale or not for rent is "0") Meaning if house A is for sale "100,000" and not for rent "0", house B is for sale "100,000" and for rent "1,500" then I call for SALE with max_price 100,000, the result return only house B
回复

使用道具 举报

 楼主| 发表于 29-8-2019 07:23 PM | 显示全部楼层
如果你忙就不用紧
回复

使用道具 举报

 楼主| 发表于 30-8-2019 10:22 AM | 显示全部楼层
成功解决啦
回复

使用道具 举报

发表于 2-9-2019 02:22 PM | 显示全部楼层
悍马 发表于 29-8-2019 07:23 PM
如果你忙就不用紧

最近真的忙,在招兵买马。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 29-3-2024 05:48 PM , Processed in 0.081330 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表