我有兩個變量$ faceplateInstalled和$ faceplateExists,我把它們打印成兩列刪除重複行,如果兩個變量匹配PHP
Faceplate Exists Faceplate Instaled
1 1
1 0
1 1
0 0
1 1
1 0
1 1
1 1
0 0
0 0
1 0
有沒有一種方法,以消除在那裏我一個相同的1和1項行?
這是一個查詢使用:
"SELECT F.id AS faceplateId, PR.premiseId, ComposeAddressFromPAF(PR.postAddressId) AS fullAddress, " .
" IF(F.id IS NOT NULL, 1, 0) AS faceplateExists, " .
" IFNULL(F.installed, 0) AS faceplateInstalled, " .
" PR.siteId, S.NAME AS siteName " .
"FROM ho_crm_premise PR " .
" LEFT JOIN ho_faceplate F ON F.premiseId = PR.premiseId " .
" INNER JOIN bcube_site S ON S.SITEID = PR.siteId " .
"WHERE S.SITEID";
,這是全功能
function GetFaceplates($siteId)
{
$sSql =
"SELECT F.id AS faceplateId, PR.premiseId, ComposeAddressFromPAF(PR.postAddressId) AS fullAddress, " .
" IF(F.id IS NOT NULL, 1, 0) AS faceplateExists, " .
" IFNULL(F.installed, 0) AS faceplateInstalled, " .
" PR.siteId, S.NAME AS siteName " .
"FROM ho_crm_premise PR " .
" LEFT JOIN ho_faceplate F ON F.premiseId = PR.premiseId " .
" INNER JOIN bcube_site S ON S.SITEID = PR.siteId " .
"WHERE S.SITEID";
if($siteId)
{
$sSql .= " AND PR.siteId = " . $siteId . " ";
}
$pResult = $this->ExecuteSQL($sSql);
return $pResult;
}
$db = new DatabaseInfinity();
$action = $_REQUEST["action"];
//$action = "SEARCH"; // TEMPORARY
$siteId = $_REQUEST["siteId"];
if($action == "SEARCH")
{
$faceplates = $db->GetFaceplates($siteId);
while($faceplate = FetchObject($faceplates))
{
$tpl->newBlock("FACEPLATE");
$tpl->assign("ID", $faceplate->faceplateId);
$tpl->assign("PREMISEID", $faceplate->premiseId );
$tpl->assign("ADDRESS", $faceplate->fullAddress);
$tpl->assign("SITEID", $faceplate->siteId);
$tpl->assign("SITENAME", $faceplate->siteName);
$tpl->assign("FEXISTS", $faceplate->faceplateExists);
$tpl->assign("FINSTALED", $faceplate->faceplateInstalled);
}
}
數據存儲爲數組?或者作爲一個字符串......? –
歡迎來到Stack Overflow!這個問題在信息上有點短暫。你可以分享你的嘗試,以及你遇到了什麼問題? –
這會讓所有人都猜到,*不是Sam嗎?* - @JayBlanchard現在已經發布了一個答案,並且在事實*之後獲得了某些內容*。 Oufff! –