Im working on a school project and i want to pass more then one value thru the url.
The page show more then one user from the Database.
This is what im trying to do so far, and i get a
Parse error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number in C:xampphtdocsadmin.php on line 79
This is the code im trying to use
<?php
//loop over alle reservationerne og display dem i en table, hvis de ikke er tomme
$num=mysqli_num_rows($query);
if($num>0)
{
while($result=mysqli_fetch_assoc($query))
{
echo "
<div class='table-card'>
<div class='table-num'>
<div class='table'><a>Bord " .$result["Bord"]."</a></div>
<div class='fjern'><a OnClick="return confirm('Er du sikker på du vil slette reservationen');" href='admin.php?id=$result['ID']&navn=$result['Navn']'>X</a></div>
</div>
<div class='table-info'>
And this is the part giving me trouble
<div class='fjern'><a OnClick="return confirm('Er du sikker på du vil slette reservationen');" href='admin.php?id=$result['ID']&navn=$result['Navn']'>X</a></div>
<?php
// Initialize the session
session_start();
// Tjek om brugeren er logget ind, hvis ikke redirect dem til login siden
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
//connect til databasen
require_once "config.php";
//Få fat på id så vi kan delete bestemte reservationer
if(isset($_GET['id']))
{
$id=$_GET['id'];
$navn=$_GET['Navn'];
$sql = "INSERT INTO `reject`(`ID`, `Navn`)
VALUES (?, ?)";
$stmt = $link->prepare($sql);
$stmt->bind_param("is", $id, $navn);
$stmt->execute();
$delete = "DELETE FROM reservation WHERE ID=$id;";
$svar = $link->query($delete);
}
//setup så vi kan vise reservationerne
$select ="select * from reservation ORDER BY Klok";
$query = $link->query($select);
$link -> close();
?>
2
Answers
Adding the curly brackets seems to have done the trick now :)
Thx for the help everyone
Will generate
If I fake up an results array like this