Modifier le résultat d'un select
Bonjour a tous
J'ai une base de données contenant des membres, des entreprises et des stages, et un site web avec lequel accéder.
J'ai une page ou je dois accéder a des données, pour soit : les voir, les modifier, les supprimer et les ajouter.
J'avais bel et bien imaginé un formulaire ou je rentre l'ID de ce que je veux avec les champs derrière pour les modifier, mais a condition de rentrer dans les zones de texte ce que je veux modifier, et je suis obligé de tout modifier car en laissant la case vide, ça renvoie une chaine vide a la place des données de base.
Y'a t'il donc moyen, en php, d'obtenir avec mon select un tableau récupérant mes données (ça, j'ai réussi) mais ensuite, avec un clic par dessus, de les modifier directement en ayant préconstruit la requête ? Car j'ai du mal a réaliser ça
Je vous montre ma requête select :
Code:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| <?php
session_start();
require("../Modeles/M_fonctions.php");
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../../ressources/css/styletable.css">
<title>Recherche de membres</title>
</head>
<body>
<?php
$db = new PDO($dbcon, $dbuser, $dbpwd);
// Compte le nombre de
$reponse = $db->query('SELECT COUNT(*) AS total FROM personne');
$total_lignes = $reponse->fetch()['total'];
$limite = 5;
$nbre_pages = ceil($total_lignes / $limite);
$page = (isset($_GET['page']) and $_GET['page'] > 0) ? $_GET['page'] : 1;
$page = (isset($_GET['page']) and $_GET['page'] > $nbre_pages) ? $nbre_pages : $page;
$debut = ($page - 1) * $limite;
$reponse = $db->prepare('SELECT
stage.ID_Stage,
stage.Descriptif_stage,
stage.Note_etudiant_stage,
stage.Duree_stage,
stage.Base_remuneration,
stage.Date_offre,
stage.Type_promos,
entreprise.Nom_entreprise,
localisation.Pays,
localisation.Ville
FROM
stage INNER JOIN
entreprise ON stage.ID_Entreprise = entreprise.ID_Entreprise INNER JOIN
localisation On localisation.ID_Entreprise = entreprise.ID_Entreprise
ORDER BY ID_Stage ASC LIMIT :debut, :limite');
$reponse->bindValue('debut', $debut, PDO::PARAM_INT);
$reponse->bindValue('limite', $limite, PDO::PARAM_INT);
$reponse->execute() || die('Impossible de charger la page');
?>
<table>
<thead>
<tr>
<th>ID</th>
<th>Poste</th>
<th>Note étudiant</th>
<th>Durée (semaine)</th>
<th>Salaire ()</th>
<th>Date de début</th>
<th>Promo visée</th>
<th>Entreprise</th>
<th>Pays</th>
<th>Ville</th>
<th>Favori<th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="8">
<?php
if ($page > 1) {
?>
<a href="?page=<?php echo $page - 1; ?>">⊲</a>
<?php
} else {
?>
<span class="invalide">⦰</span>
<?php
}
for ($i = 1; $i <= $nbre_pages; $i++) {
if ($i != $page) {
echo '<a href="?page=' . $i . '">' . $i . '</a> ';
} else {
echo '<span>' . $i . '</span> ';
}
}
if ($page < $nbre_pages) {
?>
<a href="?page=<?php echo $page + 1; ?>">⊳</a>
<?php
} else {
?>
<span class="invalide">⦰</span>
<?php
}
?>
</th>
</tr>
</tfoot>
<tbody>
<?php
for ($i = 0; $i < $limite; $i++) {
$debut++;
echo '<tr>';
if ($donnees = $reponse->fetch()) {
echo '<td>' . $donnees['ID_Stage'] . '</td>';
echo '<td>' . $donnees['Descriptif_stage'] . '</td>';
echo '<td>' . $donnees['Note_etudiant_stage'] . '</td>';
echo '<td>' . $donnees['Duree_stage'] . '</td>';
echo '<td>' . $donnees['Base_remuneration'] . '</td>';
echo '<td>' . $donnees['Date_offre'] . '</td>';
echo '<td>' . $donnees['Type_promos'] . '</td>';
echo '<td>' . $donnees['Nom_entreprise'] . '</td>';
echo '<td>' . $donnees['Pays'] . '</td>';
echo '<td>' . $donnees['Ville'] . '</td>';
} else {
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
echo '<td class="cellule_vide"></td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
</body>
</html> |