我有一个问题,我正在做一个项目在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 their is a problem connecting to the table
else {
echo "Error: could not prepare SQL statement".$mysqli->error;
}
}
在试图运行此,我感到我有附近的语法错误的错误“在第2行,但我没有”上线2 符号有人能看到我在做什么错?
为了让您知道,在这里禁止“寻求帮助”。这个网站是关于问题,而不是援助。 –
欢迎来到 – Steve73NI
没有愚蠢的编辑会有所帮助。这不是关于措辞,而是关于*问题*。无论你怎么说,你的“问题”仍然是“援助”。 –