我在尝试弄清楚如何在where子句中添加另一列时不确定如何执行此操作时遇到问题。我需要它有FIRSTNAME和LASTNAME,因为现有数据库有两列。
<?php
header('Content-Type: application/json');
try {
$dbName = "C:\\inetpub\\wwwroot\\fpdb\\staffing.mdb";
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)};charset=UTF-8; DBQ=$dbName; Uid=; Pwd=;");
}
catch (PDOException $e) {
echo $e->getMessage();
}
$Employee_Name= trim($_POST["Employee_Name"]);
$params = array( ':FIRSTNAME' => $Employee_Name);
$query = $db->prepare("
SELECT * FROM tbl_USERS
WHERE FIRSTNAME=:FIRSTNAME");
$query->execute($params);
$result = $query->fetch(PDO::FETCH_ASSOC);
$EMPLOYEE_NUMBER=trim('EMPLOYEE_NUMBER');
$rc= $result[$EMPLOYEE_NUMBER];
echo json_encode ($rc);
?>
答案 0 :(得分:1)
$Employee_Name= trim($_POST["Employee_Name"]);
$params = array( ':FIRSTNAME' => $Employee_Name, ':LASTNAME'=>$Employee_Lastname );
$query = $db->prepare("
SELECT * FROM tbl_USERS
WHERE FIRSTNAME=:FIRSTNAME and LASTNAME=:LASTNAME");
我猜猜上面的列名,但通常是正确的想法