Hi mates,
If I run the following query alone, I get the results I am after:
The result I am after in the query above is based on
where b.BidType = '".ms_escape_string($_GET["bidType"])."' AND b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
However, if I run these two queries together:
only the first IF statement where b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
runs. The second is ignored.
Any ideas why?
If I run the following query alone, I get the results I am after:
Code:
if (isset($_GET["bidStatus"]) && isset($_GET["bidType"])) {
$sql = " SELECT c.* FROM (
SELECT ROW_NUMBER() OVER(ORDER BY b.ID) AS RowID,CONVERT(VARCHAR(11), b.BidDate, 106) BidDate,CONVERT(VARCHAR(11), b.DueDate, 106) DueDate, b.DueTime, replace(b.BidTitle,',','-') BidTitle, b.BidID, da.DeptAlias, b.BidType, CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe CONVERT(VARCHAR(11), b.AwardDate, 106) END AS AwardDate, CASE WHEN b.LastUpdate='01/01/1900' THEN NULL ELSE CONVERT(VARCHAR(11), b.LastUpdate, 106) END AS LastUpdate, s.Status,
cat.Category,t.Team
FROM bids b inner join DeptALIAS da on b.AliasID = da.AliasID left join Teams t on b.TeamID = t.TeamID left join Categories cat on b.CategoryID = cat.CategoryID inner join Dept d on da.DeptCode =d.DeptCode inner join Status s on b.BidStatus=s.StatusId where b.BidType = '".ms_escape_string($_GET["bidType"])."' AND b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
) AS c
";
The result I am after in the query above is based on
where b.BidType = '".ms_escape_string($_GET["bidType"])."' AND b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
However, if I run these two queries together:
Code:
if (isset($_GET["bidStatus"]) && $_GET['bidStatus'] != '' ) {
$sql = " SELECT c.* FROM (
SELECT ROW_NUMBER() OVER(ORDER BY b.ID) AS RowID,CONVERT(VARCHAR(11), b.BidDate, 106) BidDate,CONVERT(VARCHAR(11), b.DueDate, 106) DueDate, b.DueTime, replace(b.BidTitle,',','-') BidTitle, b.BidID, da.DeptAlias, b.BidType, CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe CONVERT(VARCHAR(11), b.AwardDate, 106) END AS AwardDate, CASE WHEN b.LastUpdate='01/01/1900' THEN NULL ELSE CONVERT(VARCHAR(11), b.LastUpdate, 106) END AS LastUpdate, s.Status,
cat.Category,t.Team
FROM bids b inner join DeptALIAS da on b.AliasID = da.AliasID left join Teams t on b.TeamID = t.TeamID left join Categories cat on b.CategoryID = cat.CategoryID inner join Dept d on da.DeptCode =d.DeptCode inner join Status s on b.BidStatus=s.StatusId where b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
) AS c
";
}
elseif (isset($_GET["bidStatus"]) && isset($_GET["bidType"])) {
$sql = " SELECT c.* FROM (
SELECT ROW_NUMBER() OVER(ORDER BY b.ID) AS RowID,CONVERT(VARCHAR(11), b.BidDate, 106) BidDate,CONVERT(VARCHAR(11), b.DueDate, 106) DueDate, b.DueTime, replace(b.BidTitle,',','-') BidTitle, b.BidID, da.DeptAlias, b.BidType, CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe CONVERT(VARCHAR(11), b.AwardDate, 106) END AS AwardDate, CASE WHEN b.LastUpdate='01/01/1900' THEN NULL ELSE CONVERT(VARCHAR(11), b.LastUpdate, 106) END AS LastUpdate, s.Status,
cat.Category,t.Team
FROM bids b inner join DeptALIAS da on b.AliasID = da.AliasID left join Teams t on b.TeamID = t.TeamID left join Categories cat on b.CategoryID = cat.CategoryID inner join Dept d on da.DeptCode =d.DeptCode inner join Status s on b.BidStatus=s.StatusId where b.BidType = '".ms_escape_string($_GET["bidType"])."' AND b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
) AS c
";
}
only the first IF statement where b.BidStatus = '".ms_escape_string($_GET["bidStatus"])."'
runs. The second is ignored.
Any ideas why?