我有一个关于我在 php/mysql 中做的项目的问题。我正在设计一个网站,用户可以在其中记录他们的财务账户(银行账户/信用卡等)以及他们每个月每月进行的交易及其类型。我想要的是用户选择一个特定的帐户并使用 GET 我可以获取帐户 ID,并使用它来获取与该帐户名关联的所有交易。这是我的代码:
//connect to database
include ('connect-To-db.php');
//Ensure the id is appropriate
if (is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// get 'id' using GET superglobal variable
$id = $_GET['id'];
// get the credits, debits & catagory from the transactions table for that account
if ($stmt = $mysqli->prepare("SELECT `Credit`,`Debit`,`Catagory` FROM `transactions` WHERE `Accname` IN
(SELECT `Accname` FROM `Accounts` WHERE `accID`=?")) {
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($id,$Credit, $Debit, $Cat);
//Loop through the results and display in a table format
echo"<table>";
echo "<th>Credits></th><th>Debits</th><th>Catagory</th>";
while($row = $stmt->fetch()){
echo "<tr>";
echo "<td>.$Credit.</td>";
echo "<td>.$Debit.</td>";
echo "<td>.$Cat.</td>";
echo "</tr>";
}
echo "</table>";
$stmt->close();
}
// show an error if there is a problem connecting to the table
else {
echo "Error: could not prepare SQL statement".$mysqli->error;
}
}
在尝试运行它时,我收到错误消息,即我在第 2 行的 " 附近有一个语法错误,但是我在第 2 行没有 " 符号。我做错了什么?