1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<form action="" method="post">
<input type="text" name="nom" />
<input type="submit" />
</form>
<?php
if (isset($_POST['nom'])) {
$sql = 'SELECT id,nom, option,classe FROM tatable WHERE nom LIKE :nom';
$sth = $cnx->prepare($sql);
$param = array(':nom'=>'%' . $_POST['nom'] . '%');
$sth->execute($param);
}
else {
$sql = 'SELECT id,nom, option,classe FROM tatable';
$sth = $cnx->query($sql);
$sth->execute($param);
}
echo '<table>';
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>'
echo '<td>' . htmlspecialchars($row['id']) . '</td>';
echo '<td>' . htmlspecialchars($row['nom']) . '</td>';
echo '<td>' . htmlspecialchars($row['option']) . '</td>';
echo '<td>' . htmlspecialchars($row['classe']) . '</td>';
echo '</tr>'
}
echo '</table>'; |
Partager