在 SQLManagement Studio 中运行此查询会返回 162 行的结果集
SELECT order_num,
status,
ship_date,
cust_ord_num,
weight,
carrier_desc,
consignee,
cases
FROM v1oemf
WHERE ACCOUNT = 'NESTLE'
AND status LIKE '%Shipped%'
AND ( ship_date BETWEEN '20120327' AND '20120403' )
我从echo
我的 PHP 页面上的这段代码的结果中得到的
echo "SELECT Order_num,Status,Ship_date,Cust_ord_num,Weight,Carrier_desc,Consignee,Cases FROM V1OEMF WHERE Account = '" . $_POST['account'] . "' AND Status LIKE '%". $_POST['custstat'] ."%' AND (Ship_date BETWEEN '".$_POST['start_date']."' AND '".$_POST['end_date']."')";
$rs=odbc_exec($link,"SELECT Order_num,Status,Ship_date,Cust_ord_num,Weight,Carrier_desc,Consignee,Cases FROM V1OEMF WHERE Account = '" . $_POST['account'] . "' AND Status LIKE '". $_POST['custstat'] ."' AND Ship_date BETWEEN '".$_POST['start_date']."' AND '".$_POST['end_date']."'");
基于 PHP 的查询的结果集是 0 行,我一辈子都看不到这个问题......
这是应该建立结果表的整个部分
$rs=odbc_exec($link,"SELECT Order_num,Status,Ship_date,Cust_ord_num,Weight,Carrier_desc,Consignee,Cases FROM V1OEMF WHERE Account = '" . $_POST['account'] . "' AND Status LIKE '". $_POST['custstat'] ."' AND Ship_date BETWEEN '".$_POST['start_date']."' AND '".$_POST['end_date']."'");
$num = odbc_num_rows($rs);
echo $num;
echo "<table>";
echo "<thead><tr class='header'>";
echo "<td>Order #</td><td>Status</td><td>Ship Date</td><td>Sales Order #</td><td>Consignee</td><td>Carrier</td><td>Cases</td><td>Weight</td>";
echo "</tr></thead>";
while (odbc_fetch_row($rs)) {
echo "<tr><td id='f1'><a class='ow' href='' id='" . odbc_result($rs,'Order_num') . "'>" . odbc_result($rs,'Order_num') . "</a></td><td id='f2'>" . odbc_result($rs,'Status') . "</td><td id='f3'>" . odbc_result($rs,'Ship_date') . "</td><td id='f5'>" . odbc_result($rs,'Cust_ord_num') . "</td><td id='f6'>" . odbc_result($rs,'Consignee') . "</td><td id='f7'>" . odbc_result($rs,'Carrier_desc') . "</td><td id='f8' align='right'>" . odbc_result($rs,'Cases') . "</td><td id='f9' align='right'>" . odbc_result($rs,'Weight') . "</td></tr>";
}
echo "</table>";