[英]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.