Reputation: 1
I have a small problem, or I just can't find the solution. I have follow code in my site place.php
<?php $con = mysqli_connect("localhost", "root", "", "vmaxdbweb"); $res = mysqli_query($con, "SELECT * FROM tblplatz");
// Tabellenbeginn
echo "<table class='tbl'>";
// Überschrift
echo "<th>ID</th> <th>Bezeichung</th> <th>Code</th>";
echo "<th>Notizen & Beurteilung</th> <th>Geodaten</th> <th>Details</th>";
$lf = 1;
while ($dsatz = mysqli_fetch_assoc($res))
{
// Speichere die Daten in der Sitzung mit dem Schlüssel 'pla_id'
echo "<tr>";
echo "<td>" . $dsatz["pla_id"] . "</td>";
echo "<td>" . $dsatz["pla_bezeichnung"] . "</td>";
echo "<td>" . $dsatz["pla_code"] . "</td>";
echo "<td>" . $dsatz["pla_notiz_beurteilung"] . "</td>";
echo "<td>" . $dsatz["pla_geodaten"] . "</td>";
echo "<td><a href='content\placedetail.php?id=".$dsatz["pla_id"]."'>Details</a></td>";
$lf = $lf + 1;
}
// Tabellenende
echo "</tabelle>";
mysqli_close($con);
?>
my laylout on the website looks like this
<!DOCTYPE html>
<html lang="en">
<?php include __DIR__.'/header.inc.php' ?>
<body>
<div class ="banner">
<h4>VmaxDB Web</h4>
</div>
<div class = "main">
<div class = "menu">
<header class="container">
<?php include __DIR__.'/nav.inc.php' ?>
</header>
</div>
<div class = "stage">
<div class = "stage-header">
<?=$title?>
</div>
<div class = "content">
<main class="container">
<?php include __DIR__.'/../content/'.$currentPage.'.php' ?>
</main>
</div>
</div>
</div>
<div>
<?php include __DIR__.'/footer.inc.php' ?>
</div>
</body>
</html>
and i would like open the link
echo "<td><a href='content\placedetail.php?id=".$dsatz["pla_id"]."'>Details</a></td>";
from site place.php
in the content/container place
Does anyone happen to have an idea? :) I've tried many things, unfortunately I can't find the solution, it always opens a new tab.
Upvotes: 0
Views: 88
Reputation: 97948
Links in HTML are just a way to tell the browser to go to a new URL. They don't load content into a particular part of the page, or interact with the current page in any way.
So the simple answer is to make your link point to a complete page, which repeats the parts you want to be the same - such as your existing includes for header and footer. The PHP code can decide dynamically what to show based on query string parameters available in the $_GET
array.
That said, there are two main ways you can load content into part of the page:
<iframe>
tag, which you could very roughly think of as embedding an extra browser tab inside the content. See for instance the MDN guide to the iframe
element.fetch
API.Both techniques are a lot more fiddly to get right than just loading a full new page - particularly to avoid annoying users by breaking features like bookmarks and back/forward buttons.
Upvotes: 0