PHP 还是新手!我想从一个类别名称中选择一些产品,但没有得到任何结果。有什么建议么?
我在 MS Access 中创建了一个产品表和类别表:
Category
字段为CategoryID
, ProductID
, 和Category
头、雕塑和花瓶记录。
Products
字段是ProductID
、ProductName
、Price
和Details
。
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$connString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\ectserver\\AHARDEN2\\Database\\products.mdb";
//creates the connection object and define the connection string
$conn->Open($connString);
$selectCommand="SELECT ProductName, Price, Details FROM Products WHERE ProductID = Head";
$rs = $conn->Execute($selectCommand);
//opens a recordset from the connection object
if (!$rs->EOF){
$ProductName = $rs->Fields("ProductName");
$Price = $rs->Fields("Price");
$Details = $rs->Fields("Details");
}
print "You selected the following product last time:<p>";
print "<div id=\"category\"> ";
print "Product Name: $ProductName<br>";
print "Price: $Price<br>";
print "Details: $Details<br>";
print "</div>";
$rs->Close;