parse error
het bevind zich in de regel van delete.php ( als je op delete klikt moet de rij verwijdert worden )
code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>bestellingen</title>
<meta http-equiv="refresh" content="5" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style type="text/css">
.box{
padding: 10px;
margin-right: 50px;
margin-left: 50px;
width:400px;
}
</style>
</head>
<body >
<!-- *************************NAVIGATION BAR ************************* -->
<div class="navbar navbar-expand-lg navbar-light bg-light-inverse justify-content-center bg-danger">
<div>
<img src="McD.png" height=48 width = 48 alt="McDonalds">
</div>
<div class="navbar-brand font-italic">
<h1>bestellingen</h1>
</div>
</div>
<?php
session_start();
include 'db.php';
$query = "Select * from custdetails";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$table_query = "SELECT * from custdetails";
$result = mysqli_query($con,$table_query);
echo "<form method ='POST'>";
echo "<br><br><center><div class='navbar-brand font-italic'><h3>bestellingen</h3></div></center";
echo " <br><table class='table table-striped bg-warning table-bordered table-hover table-sm'>"."<tr>";
echo " <tr> <td> Order Number </td>
<td> Date and Time </td>
<td> Table Number </td>
<td> Name </td>
<td> Mobie Number </td>
<td> Order Contents </td>
<td> Payable Amount </td>
<td> order ok </td>
</tr>";
while($rows = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
echo "<tr>
<td>".$rows['orderno']. "</td>
<td>".$rows['datetime']. "</td>
<td>".$rows['TableNo']. "</td>
<td>".$rows['name']. "</td>
<td>".$rows['mobile_number']. "</td>
<td>".$rows['order_contents']. "</td>
<td>".$rows['payable_amount']. "</td>
[b] <td>"<a href="delete.php?id=$rows['orderno']">Edit</a>"</td>
[/b] </tr>";
}
echo "</table>";
?>
</body>
</html>
<html>
<head>
<title>bestellingen</title>
<meta http-equiv="refresh" content="5" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style type="text/css">
.box{
padding: 10px;
margin-right: 50px;
margin-left: 50px;
width:400px;
}
</style>
</head>
<body >
<!-- *************************NAVIGATION BAR ************************* -->
<div class="navbar navbar-expand-lg navbar-light bg-light-inverse justify-content-center bg-danger">
<div>
<img src="McD.png" height=48 width = 48 alt="McDonalds">
</div>
<div class="navbar-brand font-italic">
<h1>bestellingen</h1>
</div>
</div>
<?php
session_start();
include 'db.php';
$query = "Select * from custdetails";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$table_query = "SELECT * from custdetails";
$result = mysqli_query($con,$table_query);
echo "<form method ='POST'>";
echo "<br><br><center><div class='navbar-brand font-italic'><h3>bestellingen</h3></div></center";
echo " <br><table class='table table-striped bg-warning table-bordered table-hover table-sm'>"."<tr>";
echo " <tr> <td> Order Number </td>
<td> Date and Time </td>
<td> Table Number </td>
<td> Name </td>
<td> Mobie Number </td>
<td> Order Contents </td>
<td> Payable Amount </td>
<td> order ok </td>
</tr>";
while($rows = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
echo "<tr>
<td>".$rows['orderno']. "</td>
<td>".$rows['datetime']. "</td>
<td>".$rows['TableNo']. "</td>
<td>".$rows['name']. "</td>
<td>".$rows['mobile_number']. "</td>
<td>".$rows['order_contents']. "</td>
<td>".$rows['payable_amount']. "</td>
[b] <td>"<a href="delete.php?id=$rows['orderno']">Edit</a>"</td>
[/b] </tr>";
}
echo "</table>";
?>
</body>
</html>
Edit:
Ik heb code-tags geplaatst. Gelieve dit in het vervolg zelf toe te voegen aan je bericht.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Gewijzigd op 07/08/2020 21:42:26 door - Ariën -
Om het escapen met een \ van de HTML "-quotes te voorkomen kan je beter een echo gebruiken met een single-quote ( ' ). Het is eigenlijk nog beter om hele lappen HTML buiten je PHP-blok te houden.
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
echo "<tr>
<td>".$rows['orderno']. "</td>
<td>".$rows['datetime']. "</td>
<td>".$rows['TableNo']. "</td>
<td>".$rows['name']. "</td>
<td>".$rows['mobile_number']. "</td>
<td>".$rows['order_contents']. "</td>
<td>".$rows['payable_amount']. "</td>
<td>"<a href="delete.php?id=$rows['orderno']">Edit</a>"</td>
</tr>";
<td>".$rows['orderno']. "</td>
<td>".$rows['datetime']. "</td>
<td>".$rows['TableNo']. "</td>
<td>".$rows['name']. "</td>
<td>".$rows['mobile_number']. "</td>
<td>".$rows['order_contents']. "</td>
<td>".$rows['payable_amount']. "</td>
<td>"<a href="delete.php?id=$rows['orderno']">Edit</a>"</td>
</tr>";
Brecht werbrouck op 07/08/2020 21:57:01:
Nee dat zijn dubbele-quotes, geen single-quotes.
Of doe makkelijker, zonder het mengen van HTML in PHP.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
while($rows = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
?>
<tr>
<td><?php echo $rows['orderno'];?></td>
<td><?php echo $rows['datetime'];?></td>
<td><?php echo $rows['TableNo'];?></td>
<td><?php echo $rows['name'];?></td>
<td><?php echo $rows['mobile_number'];?></td>
<td><?php echo $rows['order_contens'];?></td>
<td><?php echo $rows['payable_amout'];?></td>
<td><a href="delete.php?id=<?php echo $rows['orderno'];?>">Edit</a>"</td>
</tr>
<?php
}
?>
while($rows = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
?>
<tr>
<td><?php echo $rows['orderno'];?></td>
<td><?php echo $rows['datetime'];?></td>
<td><?php echo $rows['TableNo'];?></td>
<td><?php echo $rows['name'];?></td>
<td><?php echo $rows['mobile_number'];?></td>
<td><?php echo $rows['order_contens'];?></td>
<td><?php echo $rows['payable_amout'];?></td>
<td><a href="delete.php?id=<?php echo $rows['orderno'];?>">Edit</a>"</td>
</tr>
<?php
}
?>
Gewijzigd op 07/08/2020 22:22:26 door - Ariën -
https://www.php.net/manual/en/class.domdocument.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
libxml_disable_entity_loader(TRUE);
libxml_use_internal_errors(TRUE);
$Dom = $oDomImplementation->createDocument('', '',
(new DOMImplementation)->createDocumentType('html'));
$Dom->preserveWhiteSpace = FALSE;
$Dom->formatOutput = FALSE;
$Dom->substituteEntities = TRUE;
$Dom->xmlVersion = '1.0';
$Dom->encoding = 'UTF-8';
// ...
print $Dom->saveHTML($Dom);
?>
libxml_disable_entity_loader(TRUE);
libxml_use_internal_errors(TRUE);
$Dom = $oDomImplementation->createDocument('', '',
(new DOMImplementation)->createDocumentType('html'));
$Dom->preserveWhiteSpace = FALSE;
$Dom->formatOutput = FALSE;
$Dom->substituteEntities = TRUE;
$Dom->xmlVersion = '1.0';
$Dom->encoding = 'UTF-8';
// ...
print $Dom->saveHTML($Dom);
?>
thanks!
Natuurlijk zijn er ook uitzonderingen waarbij dit niet altijd helemaal netjes opgaat, maar in het algemeen werkt dit vrij goed.
Het is mijn ervaring dat dit, als je eenmaal in deze "modus" zit, de leesbaarheid van code (enorm) bevordert.
Toegepast op het bovenstaande stuk code wordt dit, na enige fatsoenering:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
while ($rows = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
?><tr>
<td><?php echo $rows['orderno']; ?></td>
<td><?php echo $rows['datetime']; ?></td>
<td><?php echo $rows['TableNo']; ?></td>
<td><?php echo $rows['name']; ?></td>
<td><?php echo $rows['mobile_number']; ?></td>
<td><?php echo $rows['order_contens']; ?></td>
<td><?php echo $rows['payable_amout']; ?></td>
<td><a href="delete.php?id=<?php echo $rows['orderno']; ?>">Edit</a></td>
</tr><?php
}
?>
while ($rows = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
?><tr>
<td><?php echo $rows['orderno']; ?></td>
<td><?php echo $rows['datetime']; ?></td>
<td><?php echo $rows['TableNo']; ?></td>
<td><?php echo $rows['name']; ?></td>
<td><?php echo $rows['mobile_number']; ?></td>
<td><?php echo $rows['order_contens']; ?></td>
<td><?php echo $rows['payable_amout']; ?></td>
<td><a href="delete.php?id=<?php echo $rows['orderno']; ?>">Edit</a></td>
</tr><?php
}
?>
Ook zou ik je aanraden je (verder) te verdiepen in character encod(er)ing(en) en het escapen van output. Dit gaat op den duur een grote en belangrijke rol spelen wanneer je van dit soort administratieve systemen aan het bouwen bent. Indien niet of verkeerd toegepast kan dit tot heel veel hoofdpijn en/of veiligheidslekken leiden.