Hej Alle
Har et lille problem, som jeg håber nogle kan hjælpe mig med.
Jeg har nogle informationer fra en database, som jeg viser i en tabel. I denne tabel har jeg forskellige kolonner.
En af kolonnerne indeholder data fra databasen kaldet TrackingStatus. TrackingStatus kan have følgende værdi:
StatusREL, StatusSHP, StatusINV, StatusNR
Det jeg ønsker er kun at vise data, som har værdierne StatusREL, StatusINV og StatusNR. Altså udelade de data som har værdien StatusSHP.
Herunder er min kode, som den ser ud nu:
if (trim($_SESSION['ShowDetails']) == "Y") {
$query = "SELECT TrackingNbr,Revision,ShipVia,PONbr,DrawPN,BuildStatus,ShipTrackNbr1,";
$query = $query . "SType,CustomerName,CurrentGate,TrackingStatus,LastMoveDateTime,CustID,DockDate,ShipDate";
$query = $query . " FROM JTSStatu";
if (trim($_SESSION['WebUserType']) == "Rep") {
$query = $query . " WHERE ((SalesRep1 = '";
$query = $query . trim($_SESSION['SalesRepID']) . "')";
$query = $query . " or (SalesRep2 = '" . trim($_SESSION['SalesRepID']) . "')";
$query = $query . " or (SalesRep3 = '" . trim($_SESSION['SalesRepID']) . "')";
$query = $query . " or (SalesRep4 = '" . trim($_SESSION['SalesRepID']) . "'))";
} else {
$query = $query . " WHERE (CustID = '";
$query = $query . $_SESSION['SavedCustID'] . "')";
}
} else {
$query = "SELECT TrackingNbr,Revision,ShipVia,PONbr,DrawPN,TrackingStatus,BuildStatus,ShipTrackNbr1,SType,ShipDate FROM JTSStatu WHERE (CustID = '";
$query = $query . $_SESSION['SavedCustID'] . "')";
}
if (trim($_POST['SearchType']) == "PONbr") {
if (trim($_POST['SearchValue']) != "") {
$query = $query . " AND PONbr LIKE '" . trim($_POST['SearchValue']) . "%'";
}
}
if (trim($_POST['SearchType']) == "PartNbr") {
if (trim($_POST['SearchValue']) != "") {
$query = $query . " AND (DrawPN LIKE '" . trim($_POST['SearchValue']) . "%')";
}
if (trim($_POST['SearchRev']) != "") {
$query = $query . " AND (Revision = '" . trim($_POST['SearchRev']) . "')";
}
}
if (trim($_POST['SearchType']) == "JobNbr") {
if (trim($_POST['SearchValue']) != "") {
$query = $query . " AND (TrackingNbr LIKE '" . trim($_POST['SearchValue']) . "%')";
}
}
if (trim($_POST['SearchType']) == "NotShipped") {
$query = $query . " AND (BuildStatus NOT LIKE 'Shipped%')";
}
if (trim($_SESSION['ShowDetails']) == "Y") {
if (trim($_SESSION['SavedCustID']) != "All") {
$query = $query . " AND (CustID = '" . $_SESSION['SavedCustID'] . "')";
}
$andused = false;
if (trim($_SESSION['StatusREL']) == "Y") {
$query = $query . " AND (TrackingStatus = '" . trim($_SESSION['StatusREL']) . "'";
$andused = true;
}
if (trim($_SESSION['StatusSHP']) == "S") {
if (!$andused) {
$query = $query . " AND (TrackingStatus = '" . trim($_SESSION['StatusSHP']) . "'";
$andused = true;
} else {
$query = $query . " OR TrackingStatus = '" . trim($_SESSION['StatusSHP']) . "'";
}
}
if (trim($_SESSION['StatusINV']) == "I") {
if (!$andused) {
$query = $query . " AND (TrackingStatus = '" . trim($_SESSION['StatusINV']) . "'";
$andused = true;
} else {
$query = $query . " OR TrackingStatus = '" . trim($_SESSION['StatusINV']) . "'";
}
}
if (trim($_SESSION['StatusNR']) == "NR") {
if (!$andused) {
$query = $query . " AND (TrackingStatus = ' '" ;
$andused = true;
} else {
$query = $query . " OR TrackingStatus = ' '";
}
}
if (trim($_POST['FromDate']) != "" AND trim($_POST['ToDate']) != "") {
$query = $query . " AND (DockDate >= '" . trim($_POST['FromDate']) . "' AND DockDate <= '" . trim($_POST['ToDate']) . "')";
}
// Now put on the closing paren
if (trim($_SESSION['StatusREL']) == "Y" || trim($_SESSION['StatusNR']) == "NR"
|| trim($_SESSION['StatusSHP']) == "S" || trim($_SESSION['StatusINV']) == "I" ) {
$query = $query . " )";
}
}
og
<tr><td>
<?php
if (trim(ads_result($jtsstatus,"TrackingStatus")) == "") { echo("Not Released"); }
if (trim(ads_result($jtsstatus,"TrackingStatus")) == "Y") { echo("Released"); }
if (trim(ads_result($jtsstatus,"TrackingStatus")) == "S") { echo("Shipped"); }
if (trim(ads_result($jtsstatus,"TrackingStatus")) == "I") { echo("Invoiced"); }
if (trim(ads_result($jtsstatus,"TrackingStatus")) == "L") { echo("Inner Layers"); }
?>
</td></tr>