mam bazę danych z których wyciągam dane ale gdy chce dodać coś nowego to dodaje mi się tylko ostatnia pozycja i nic więcej
pokazuję kod i powiedzcie co może być nie tak?
<?php if($_GET['podstrona']=='authors') { ?>
<h1>AUTHOR's</h1>
<?php
if (isset($_POST['insertAuthor'])) {
if (date('Y-m-d') > $_POST['year_of_birth']) {
$query = $pdo->prepare("INSERT INTO author (first_name, last_name, year_of_birth)
VALUES (:first_name, :last_name, :year_of_birth)");
$query->execute(
array(':first_name'=>$_POST['first_name'], ':last_name'=>$_POST['last_name'], ':year_of_birth'=>$_POST['year_of_birth'])
);
}
if ($pdo->lastInsertId()) {
echo 'Dodadno nowego autora: <b>'.$_POST['first_name'].' '.$_POST['last_name'].'</b> urodzonego dnia '.$_POST['year_of_birth'];
unset($_POST);
} else {
echo 'Wystapil blad - popraw dane';
}
}
?>
<form method="post">
<table>
<tr>
<td><input type="text" name="first_name" id="first_name" placeholder="first_name"
maxlength="45" value="<?php echo $_POST['first_name']; ?>" /></td>
<td><input type='text' name="last_name" id="last_name" maxlength="45" placeholder="last_name"
value="<?php echo $_POST['last_name']; ?>" required /></td>
<td><input type="text" name="year_of_birth" id="year_of_birth" placeholder="year_of_birth"
value="<?php echo $_POST['year_of_birth']; ?>" required /></td>
<td><button type="submit" id="insertAuthor" name="insertAuthor">ADD!</button></td>
</tr>
<?php
$stmt = $pdo->query("SELECT * FROM author");
foreach($stmt as $row){
?>
<tr>
<td><input type='text' name='first_name' id='first_name' value='<?php echo $row['first_name']; ?>' maxlength='45' /><br /></td>
<td><input type='text' name='last_name' id='last_name' value='<?php echo $row['last_name']; ?>' maxlenght='45' /><br /></td>
<td><input type='text' name='year_of_birth' id='year_of_birth' value='<?php echo $row['year_of_birth']; ?>' /><br /></td>
<td>
<a href="update.php?id=<?php echo $row['id']; ?>">[EDIT]</a>
<a href="delete1.php?id=<?php echo $row['id']; ?>">[DELETE]</a>
</td>
</tr>
<?php }
$stmt->closeCursor();
?>
</table>
<?php } elseif($_GET['podstrona']=='shelfs') { ?>
<h1>SHELF's</h1>