School project. Am making a page which show data from db to table and should have change and delete option. I was using multiple tutorials so there is a lot of diff code. Main problem: i think i am not getting id from my table.php page. And now that i think of it i am not sure that i "connected" 2 php files, dk how to acly, but i may be wrong.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
</tr>
<th>ID</th>
<th>Ime</th>
<th>Tim</th>
<th>Bodovi</th>
<th colspan="2">Opcije</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "admin", "admin", "seminarski");
if ($conn-> connect_error) {
die("Connection Failed". $conn-> connect_error);
}
$sql = "SELECT id, racename, team, points from f1_tabela";
$result = $conn-> query($sql);
?>
<?php
while ($row = $result-> fetch_assoc()): ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['racename']; ?></td>
<td><?php echo $row['team']; ?></td>
<td><?php echo $row['points']; ?></td>
<td>
<a href="tabela.php?edit=<?php echo $row['id'];?>"> Izmjeni</a>
<a href="insert.php?delete=<?php echo $row['id'];?>"> Izbrisi</a>
</td>
</tr>
<?php endwhile; ?>
</table>
</body>
PHP proces file
if (isset($_GET['delete'])){
$id = $_GET['delete'];
$mysqli->query("DELETE FROM f1_tabela WHERE id=$id") or die($mysqli->error()); // here is error//
}
?>