繁体   English   中英

sql查询后的if else语句

[英]if else statement after sql query

因此,我有一个查询torrent_download的查询,torrent_download只能为1或0;

$sql_istorrenthere = $this->query("SELECT torrent_download
FROM " . DB_PREFIX . "auctions WHERE
                auction_id='" . $item_details['auction_id'] . "'"); 
if (empty($sql_istorrenthere))
{

        $display_output = GMSG_NOTORRENT;}
        else
        $display_output = GMSG_TORRENT;
}

我想做的就是用if (empty($sql_istorrenthere)) if $sql_istorrenthere == 1 then $display_output = GMSG_NOTORRENT; else $display_output = GMSG_TORRENT; if $sql_istorrenthere == 1 then $display_output = GMSG_NOTORRENT; else $display_output = GMSG_TORRENT;

这个怎么做?

首先,您必须获取结果行,很难告诉您如何做,因为您没有告诉我们您所使用的框架/数据库抽象层。 查看文档,您想要以数组或对象的形式获取结果。

对于数组:

尝试使用var_dump显示结果,如果成功,则将看到包含键torrent_download的数组。 然后只需将$res['torrent_download']1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM