如何在 where 子句中添加另一列
How to add another column in where clause
我在尝试弄清楚如何将另一列添加到我的 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);
?>
$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");
我猜的是上面的列名,但大体上是正确的想法
我在尝试弄清楚如何将另一列添加到我的 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);
?>
$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");
我猜的是上面的列名,但大体上是正确的想法