Как очистить get?
Как сделать кнопку назад, чтобы возвращаться ко всем записям? Я так понимаю, нужно создать функцию, которая будет очищать $_GET['id']
$query = "SELECT * FROM products";
if(isset($_GET["id"])){
$query .= " WHERE id=?";
$stmt = $link->prepare($query);
$stmt->bind_param('i', $_GET["id"]);
}
else{
$stmt = $link->prepare($query);
}
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo '<table>
<tr>
<th>ID</th>
<th>title</th>
<th>price</th>
<th>description</th>
<th>category</th>
<th>image</th>
<th>Publish by</th>
</tr>';
foreach($result as $item){
echo '<tr><td>' . $item['id'] . '</td><td>' . $item['title'] . '</td><td>' . $item['price'] . '</td><td>' . $item['description'] . '</td><td>' . $item['category'] . '</td><td>' . $item['image'] . '</td>';
if($item['active']){
echo'<td> Да </td>';
}
else{
echo '<td> Нет </td>';
}
if(!isset($_GET['id'])){
echo '<td><a href="?id='. $item['id']. '">Открыть запись</a><td></tr>';
}
}