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
| // récupère le code HTML du champ POSITION par rapport à l'IDPROJET correspondant
if (isset($_GET['IDPROJET'])) {
$idProjet = $_GET['IDPROJET'];
$traiterPosition = $bdd->prepare("SELECT POSITION FROM projet WHERE IDPROJET='$idProjet'");
$traiterPosition->execute();
while ($donnees = $traiterPosition->fetch()) {
$position = $donnees['POSITION'];
}
}
// instanciation d'un objet DomDocument
$dom = new DomDocument;
// charge le fichier contenant le tableau HTML
$dom->loadHTML($position);
// recupère toutes les balises tr, supprime les 3 dernières colonnes et affichage du résultat
$listeTr = $dom->getElementsByTagName('tr');
foreach ($listeTr as $tr) {
// liste des td du tr
$listeTd = $tr->getElementsByTagName('td');
$nMax = 5;
$n = 1;
while ($listeTd->item($nMax)) {
$tr->removeChild($listeTd->item($nMax));
}
// on affecte le nouveau code HTML à la variable $newPosition pour l'insérer à la query update
$newPosition = $tr->nodeValue;
// query modification du code HTML rentré par l'user
$updatePosition = $bdd->prepare("UPDATE bdd
SET POSITION = '$newPosition'
WHERE `projet`.`IDPROJET` = '$idProjet';");
$updatePosition->execute();
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Positions éditées avec succès !')
window.location.href='afficherProjet.php?IDPROJET=$idProjet'
</SCRIPT>");
} |
Partager