<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns= "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>modifier actualité</title> </head> <?php try { $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO('mysql:host=localhost;dbname=projet', 'root', '', $pdo_options); } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> Modification actualité <form action ="essai.php" method="post"> <label for="titre">Titre</label> : " /> <label for="contenu">Contenu</label> : <textarea name="contenu" rows="8" cols="45" id="contenu"> <?php if (isset($_POST['contenu'])) echo $_POST['contenu']; ?> </textarea> </form> <?php if (isset($_POST['contenu'])) { $req $bdd->prepare('UPDATE news SET contenu :nv_contenu WHERE titre =\'' . $_POST['titre'] . '\''); $req->execute(array( 'nv_contenu' => $_POST['contenu'] )); $req->closeCursor(); } ?> </html>
$req $bdd->prepare('UPDATE news SET contenu :nv_contenu WHERE titre =\'' . $_POST['titre'] . '\'');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns= "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>modifier actualité</title> </head> <?php try { $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO('mysql:host=localhost;dbname=projet', 'root', '', $pdo_options); } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> Modification actualité <?php if (isset($_GET['id'])) { $reponse $bdd->query('SELECT titre, contenu FROM news WHERE id :id'); while ($donnees = $reponse->fetch()) { ?> <form action="affichage_news.php" method="post"> <label for="titre">Titre</label> : " /> <label for="contenu">Contenu</label> : <textarea name="contenu" rows="8" cols="45" id="contenu"> <?php if (isset($_POST['contenu'])) echo $_POST['contenu']; ?> </textarea> </form> <?php } $reponse->closeCursor(); } if (isset($_POST['contenu'], $_POST['titre'], $_POST['id'])) { $contenu = $_POST['contenu']; $titre = $_POST['titre']; $req $bdd->prepare('UPDATE news SET contenu :contenu WHERE id = :id'); $req->bindParam(':contenu', $contenu, PDO::PARAM_STR); $req->bindParam(':titre', $titre, PDO::PARAM_STR); $req->execute(); $req->closeCursor(); } ?> </html>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionif (isset($_GET['id']))