好的,所以我在代码中向while()
添加了一个if语句。修正了一些错误,yadayada。现在我得到意外结束文件的错误。我没有关闭一些东西吗?因为我一直在寻找错误一段时间。 (是的,我知道。不是每个单词都是英语。但它们主要是名字。)
<?php
include 'inc.php';
$sql = mysqli_query($mysql, "
SELECT a.ArtID, a.Productnaam, a.Inkoopprijs, a.LevID, v.Voorraad, v.Min_voorraad
FROM artikelen a, voorraad v
WHERE a.ArtID = v.ArtID
ORDER BY a.Productnaam");
if($sql === FALSE){
die(mysqli_error());
}
?>
<nav>
<div id="menubar">
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="login.php">Login</a></li>
<li class="current"><a href="artikelenOve.php">Artikelen</a></li>
</ul>
</div>
</nav>
<div id="site_content">
<div id="content">
<div class="content_item">
<form action="artikelenOve.php" method="post">
<input type="submit" name="add" value="Voeg een artikel toe"><br><br>
<table border="1"><tr><td>ID</td>
<td>Naam</td>
<td>Inkoopprijs</td>
<td>Leverancier ID</td>
<td>Voorraad</td>
<td>Minimum</td>
<td>Wijzigen</td>
<td>Verwijderen</td></tr>
<?php
$result = $rArt['Voorraad'] - $rArt['Min_voorraad'];
while($rArt = mysqli_fetch_array($sql)){
echo '<tr><td>' . $rArt['ArtID'] . '</td>';
echo '<td>' . $rArt['Productnaam'] . '</td>';
echo '<td>' . $rArt['Inkoopprijs'] . '</td>';
echo '<td>' . $rArt['LevID'] . '</td>';
echo '<td>' . $rArt['Voorraad'] . '</td>';
echo '<td>' . $rArt['Min_voorraad'] . '</td>';
if($result < 0){
echo '<td bgcolor="red"></td>';
}elseif($result >= $rArt['Min_voorraad'] && $result <= $rArt['Min_voorraad'] * 1.2){
echo '<td bgcolor="yellow"></td>';
}else{
echo '<td bgcolor="green"></td>';
}
echo '<td><input type="submit" name="edit" value="Wijzig"></td>';
echo '<td><input type="submit" name="delete" value="Verwijder"></td></tr>';
}
if(isset($_POST['add'])){
header('Location: artikelenToe.php');
}
if(isset($_POST['edit'])){
header('Location: artikelenWij.php');
}
if(isset($_POST['delete'])){
$sql2 = mysqli_query($mysql, "
DELETE FROM voorraad v
WHERE v.ArtID = " . $_GET['delete'] . "");
$sql3 = mysqli_query($mysql, "
DELETE FROM artikelen a
WHERE a.ArtID = " . $_GET['delete'] . "");
?>
</form></table>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
</body>
</html>
答案 0 :(得分:1)
你在第70行if(isset($_POST['delete'])){
上留下一个从未关闭过的开放花括号。
更正后的代码:
<?php
include 'inc.php';
$sql = mysqli_query($mysql, "
SELECT a.ArtID, a.Productnaam, a.Inkoopprijs, a.LevID, v.Voorraad, v.Min_voorraad
FROM artikelen a, voorraad v
WHERE a.ArtID = v.ArtID
ORDER BY a.Productnaam");
if($sql === FALSE){
die(mysqli_error());
}
?>
<nav>
<div id="menubar">
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="login.php">Login</a></li>
<li class="current"><a href="artikelenOve.php">Artikelen</a></li>
</ul>
</div>
</nav>
<div id="site_content">
<div id="content">
<div class="content_item">
<form action="artikelenOve.php" method="post">
<input type="submit" name="add" value="Voeg een artikel toe"><br><br>
<table border="1"><tr><td>ID</td>
<td>Naam</td>
<td>Inkoopprijs</td>
<td>Leverancier ID</td>
<td>Voorraad</td>
<td>Minimum</td>
<td>Wijzigen</td>
<td>Verwijderen</td></tr>
<?php
$result = $rArt['Voorraad'] - $rArt['Min_voorraad'];
while($rArt = mysqli_fetch_array($sql)){
echo '<tr><td>' . $rArt['ArtID'] . '</td>';
echo '<td>' . $rArt['Productnaam'] . '</td>';
echo '<td>' . $rArt['Inkoopprijs'] . '</td>';
echo '<td>' . $rArt['LevID'] . '</td>';
echo '<td>' . $rArt['Voorraad'] . '</td>';
echo '<td>' . $rArt['Min_voorraad'] . '</td>';
if($result < 0){
echo '<td bgcolor="red"></td>';
}elseif($result >= $rArt['Min_voorraad'] && $result <= $rArt['Min_voorraad'] * 1.2){
echo '<td bgcolor="yellow"></td>';
}else{
echo '<td bgcolor="green"></td>';
}
echo '<td><input type="submit" name="edit" value="Wijzig"></td>';
echo '<td><input type="submit" name="delete" value="Verwijder"></td></tr>';
}
if(isset($_POST['add'])){
header('Location: artikelenToe.php');
}
if(isset($_POST['edit'])){
header('Location: artikelenWij.php');
}
if(isset($_POST['delete'])){
$sql2 = mysqli_query($mysql, "
DELETE FROM voorraad v
WHERE v.ArtID = " . $_GET['delete'] . "");
$sql3 = mysqli_query($mysql, "
DELETE FROM artikelen a
WHERE a.ArtID = " . $_GET['delete'] . "");
}
?>
</form></table>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
</body>
</html>
答案 1 :(得分:1)
This is a parse error which occurs when php is still looking for something and reaches the end of the file without finding it. It could be a quote or bracket which is unclosed, and php is still treating the file contents as a part of the quote.
您尚未关闭if(isset($_POST['delete'])){
添加结束括号可以解决问题..
if(isset($_POST['delete'])){
$sql2 = mysqli_query($mysql, "
DELETE FROM voorraad v
WHERE v.ArtID = " . $_GET['delete'] . "");
$sql3 = mysqli_query($mysql, "
DELETE FROM artikelen a
WHERE a.ArtID = " . $_GET['delete'] . "");
}