我正在尝试根据 sql 查询中的列是 0 还是 1 来更改表中两列的打印结果
我做了 $Status 的回显,它列出了正确值的列表,但它在我的桌子上方。我是否会错误地将其放入我的表格行中?
我的其余数据正确地填充了表格,只是这两列。我目前已将该部分注释掉,因此表中的输出分别为 0 或 1。我在特定列旁边还有一个注释掉的变量,如果它们要正确输出,它们会在哪里。
任何帮助将不胜感激。
这是我尝试进行转换的代码部分:
if ($strAdjIncrease == '0') {
$AdjIncDec == 'Decrease';
} elseif ($strAdjIncrease == '1') {
$AdjIncDec == 'Increase';
} else {
$AdjIncDec == 'Unknown';
}
if ($strAdjStatus == '0') {
$Status =='Open';
} elseif ($strAdjStatus == '1') {
$Status =='Closed';
} else {
$Status =='Void';
}
这是我的全表代码:
if (odbc_num_rows($rsIaL) == 0) {
echo "<center>";
echo "<b>We're Sorry, No Records Returned.</b><br>\n";
echo "</center>";
} else {
echo "<p align='center'>";
echo "<font face='Arial' size='4'><b>Last 31 Days Only</b></font>";
echo "</p>\n";
echo "<table border='1' align='center' cellpadding='2' style='border-collapse: collapse; font-size: 12px; font-weight: bold'>\n";
echo "<thead>";
echo "<tr>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>#</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Log ID</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Reason</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Inc/Dec</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Status</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Ref No</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Tot Cost</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Tot Retail</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>Start</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>End</b></font></th>";
echo "<th ALIGN='LEFT' bgcolor='#C0C0C0'><font face='Arial' size='2'><b>User</b></font></th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
$counter = 1;
while ($row = odbc_fetch_array($rsIaL)) {
$strAdjID = trim(odbc_result($rsIaL, "AdjID"));
$strReaDesc = trim(odbc_result($rsIaL, "ReaDesc"));
$strAdjStatus = trim(odbc_result($rsIaL, "AdjStatus"));
$strAdjRefNo = trim(odbc_result($rsIaL, "AdjRefNo"));
$strAdjStTS = trim(odbc_result($rsIaL, "AdjStTS"));
$strAdjEndTS = trim(odbc_result($rsIaL, "AdjEndTS"));
$strAdjUID = trim(odbc_result($rsIaL, "AdjUID"));
$strAdjTotCost = trim(odbc_result($rsIaL, "AdjTotCost"));
$strAdjTotRetail = trim(odbc_result($rsIaL, "AdjTotRetail"));
$strAdjIncrease = trim(odbc_result($rsIaL, "AdjIncrease"));
if ($bgcolor == '#ffffff') {
$bgcolor = '#dddddd';
} else {
$bgcolor = '#ffffff';
}
/*
I can't get this if/else portion to work and output correctly to the table!
I may be doing it incorrectly though
if ($strAdjIncrease == '0') {
$AdjIncDec == 'Decrease';
} elseif ($strAdjIncrease == '1') {
$AdjIncDec == 'Increase';
} else {
$AdjIncDec == 'Unknown';
}
if ($strAdjStatus == '0') {
$Status =='Open';
} elseif ($strAdjStatus == '1') {
$Status =='Closed';
} else {
$Status =='Void';
}
*/
echo "<tr>\n";
echo "<td bgcolor = '$bgcolor' align=center>$counter</td>\n";
echo "<td bgcolor = '$bgcolor' align=center> <a href='Inventory_Adjustments_Detail.asp?log_id=$strAdjID&store_id=$storeID'>$strAdjID</a></td>\n";
echo "<td bgcolor = '$bgcolor' align=left>$strReaDesc</td>\n";
echo "<td bgcolor = '$bgcolor' align=left>$strAdjIncrease</td>\n"; #$AdjIncDec <-if/else variable
echo "<td bgcolor = '$bgcolor' align=left>".$strAdjStatus."</td>\n"; #$Status <- if/else variable
echo "<td bgcolor = '$bgcolor' align=left>$strAdjRefNo</td>\n";
echo "<td bgcolor = '$bgcolor' align=right>$" . number_format($strAdjTotCost, 2) . "</td>\n";
echo "<td bgcolor = '$bgcolor' align=right>$" . number_format($strAdjTotRetail, 2) . "</td>\n";
echo "<td bgcolor = '$bgcolor' align=center>" . date('n-j-Y h:i:s A', strtotime($strAdjStTS)) . "</td>\n";
echo "<td bgcolor = '$bgcolor' align=center>" . date('n-j-Y h:i:s A', strtotime($strAdjEndTS)) . "</td>\n";
echo "<td bgcolor = '$bgcolor' align=left>$strAdjUID</td>\n";
echo "</tr>";
$counter++;
}
echo "</tbody>\n";
echo "</table><br>\n";
}