Mise à jour des valeurs dans les inputs
Résolu
thibautB
Messages postés
140
Date d'inscription
Statut
Membre
Dernière intervention
-
thibautB Messages postés 140 Date d'inscription Statut Membre Dernière intervention -
thibautB Messages postés 140 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un problème sur mon update, dès que j'appuie sur mon bouton pour modifier les valeurs dans mes inputs il m'affiche : echec de la requeteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ff_mois = 'remerciment confrere' lfhf_date = '2015-12-28' lfhf_montant = '1020' ' at line 1 et je ne trouve pas l'erreur voici mon code ou il y 'a le bouton modifier avec les inputs :
et le code pour mettre à jour
j'ai un problème sur mon update, dès que j'appuie sur mon bouton pour modifier les valeurs dans mes inputs il m'affiche : echec de la requeteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ff_mois = 'remerciment confrere' lfhf_date = '2015-12-28' lfhf_montant = '1020' ' at line 1 et je ne trouve pas l'erreur voici mon code ou il y 'a le bouton modifier avec les inputs :
<form method="post" action="mfhf.php" id="id_form">
<select id="choix" name="choix" onchange="actualiseInputs();">
<?php
$liendb = mysqli_init();
$connex = mysqli_real_connect($liendb, "localhost", "root","","gsb");
$requete = 'select lfhf_id, lfhf_libelle, ff_mois, lfhf_date, lfhf_montant from lignefraishorsforfait lfhf, visiteur v WHERE v.vis_matricule = lfhf.vis_matricule';
$reponse = mysqli_query($liendb,$requete);
while($ligne = mysqli_fetch_array($reponse))
{
$resultat = '<option value="'.$_SESSION['lfhf_id'].'" data-mois="'.$ligne['ff_mois'].'" data-date="'.$ligne['lfhf_date'].'" data-montant="'.$ligne['lfhf_montant'].'" >'.$ligne['lfhf_libelle'].'</option>';
echo $resultat;
$_SESSION['id'] = $ligne['lfhf_id'];
$_SESSION['libelle'] = $ligne['lfhf_libelle'];
$_SESSION['mois'] = $ligne['ff_mois'];
$_SESSION['date'] = $ligne['lfhf_date'];
$_SESSION['montant'] = $ligne['lfhf_montant'];
}
mysqli_close($liendb);
?>
</select>
<input id='input_id' type="hidden" value="">
<div id="lbi1"><label >libelle : </label><input id='input_libelle' type="text" value=""></div>
<div id="lbi2"><label>mois : </label><input id= "input_mois" type="text" value=""></div>
<div id="lbi3"><label>date : </label><input id= "input_date" type="text" value=""></div>
<div id="lbi4"><label>montant : </label><input id= "input_montant" type="text" value=""></div>
<input id="cff" type="submit" value="modifiez valeur" name="mfhf">
<script type="text/javascript">
function actualiseInputs(){
//récupération des valeurs
var select = document.getElementById("choix"); //recupère valeur choix
var choice = select.selectedIndex; //choix valeurs
var id = select.options[choice].value; //choix id
var libelle = select.options[select.selectedIndex].text; //affiche libelle
//récupération des variables DATA-QQCHOSE
var elmOption = select.options[choice]; //select mois correspondand a l'id ou libelle
var mois = elmOption.getAttribute('data-mois'); //recupere le mois
var el = select.options[choice];
var date = el.getAttribute('data-date');
var ell = select.options[choice];
var montant = ell.getAttribute('data-montant');
//remplissage des inputs
var input_id = document.getElementById('input_id'); //remplis input
input_id.value =id; //valeur de l'id = id
var input_libelle = document.getElementById('input_libelle');
input_libelle.value =libelle;
var input_mois = document.getElementById('input_mois');
input_mois.value = mois;
var input_date = document.getElementById('input_date');
input_date.value = date;
var input_montant = document.getElementById('input_montant');
input_montant.value = montant;
}
</script>
</form>
et le code pour mettre à jour
<?php
session_start();
?>
<?php
if(isset($_POST['mfhf'])) {
$liendb = mysqli_init();
$connection = mysqli_real_connect($liendb, 'localhost', 'root', '', 'gsb');
$requete = "update lignefraishorsforfait set lfhf_libelle = '".$_SESSION['libelle']."' ff_mois = '".$_SESSION['libelle']."' lfhf_date = '".$_SESSION['date']."' lfhf_montant = '".$_SESSION['montant']."' where lfhf_id = '".$_SESSION['id']."'";
$reponse = mysqli_query($liendb, $requete) or die('echec de la requete'.mysqli_error($liendb));
$ligne = mysqli_fetch_array($reponse, MYSQLI_NUM);
echo"je suis la";
mysqli_close($liendb);
}
else
{
echo"ca ne marche pas";
}
?>
A voir également:
- Mise à jour des valeurs dans les inputs
- Mise a jour chrome - Accueil - Applications & Logiciels
- Mise a jour windows 10 - Accueil - Mise à jour
- Mise a jour chromecast - Accueil - Guide TV et vidéo
- Mise a jour kindle - Guide
- Mise à jour libre office - Accueil - Bureautique
2 réponses
Bonjour
Tu as oublié la virgule entre les différents champs du UPDATE :
Tu as oublié la virgule entre les différents champs du UPDATE :
champ1='valeur1', champ2='valeur2'
thibautB
Messages postés
140
Date d'inscription
Statut
Membre
Dernière intervention
1
effectivement ca marche mieux mais ca met pas à jour et je ne comprend pas __"