Bonjour j'aimerai mettre une requête sql sur un bouton qui modifirais directement dans la base de donnée comment dois je mis prendre?
ps je travail sur phpmyadmin
Merci
Bonjour j'aimerai mettre une requête sql sur un bouton qui modifirais directement dans la base de donnée comment dois je mis prendre?
ps je travail sur phpmyadmin
Merci
Qu'est ce qui te pose problème ?
L'écriture de la requête en SQL ? L'execution de la requête en PHP ? Le bouton HTML ?
l'écriture du sql via un bouton oui_non
voici html
code pour bouton, tableau, barre de recherche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <html> <html lang="fr"> <head> <meta charset="utf-8" /> <title>Flotte Mobile</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="dialog.js"></script> <link href="Tableau.css" rel="stylesheet" /> <link rel="stylesheet" type="text/css" href="Bouton.css"> <link rel="stylesheet" href="dialog.css"> </head> <body> <h2 align="center">Affectation</h2><br /> <center> <a href="Abonnement.php" class="bouton_dans_page">Abonnement</a> <a href="Employe.php" class="bouton_dans_page"> Employe</a> <a href="Equipement.php" class="bouton_dans_page"> Equipement</a> <a href="Modele.php" class="bouton_dans_page"> Modele</a> <a href="Nouvelle_Affectation.php" class="bouton_dans_page"> Nouvelle Affectation</a> <a href="Employe.php" class="bouton_dans_page"> Employe</a> <a href="Menu_Smartphone.html" class="bouton_dans_page"> Menu Smarphone</a> </center> <div class="container"> <br /> <div class="form-group"> <div class="input-group"> <span class="input-group-addon">Recherche</span> <input type="text" name="search_text" id="search_text" placeholder="Rechercher par Nom/Opérateur/Num SIM" class="form-control" /> </div> </div> <br /> <div id="result"></div> </div> <center> <div id="dialogoverlay"></div> <div id="dialogbox"> <div> <div id="dialogboxhead"></div> <div id="dialogboxfoot"></div> </div> </div> <button class="Menu" onclick="Confirm.render()">Suprimer Affectation</button> <button class="Menu" type="button">Confirmer Retour Equipement</button> <a href="Equipement_Modal.php" class="Menu"> Remplacer Equipement</a> <button class="Menu" type="button">Ajout et Supression Ligne</button> <button class="Menu" type="button">Confirmer Retour Abonnement</button> <button class="Menu" type="button">Reaffectation Equipement</button> </center> </body> </html> <script> $(document).ready(function(){ load_data(); function load_data(query) { $.ajax({ url:"fetch_Affect.php", method:"POST", data:{query:query}, success:function(data) { $('#result').html(data); } }); } $('#search_text').keyup(function(){ var search = $(this).val(); if(search != '') { load_data(search); } else { load_data(); } }); }); </script>
oui_non.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php //PHP avant tout if (!empty($_POST)) { //la connexion $connect = mysqli_connect("localhost", "root", "Mm101010", "smartphone"); //la requete de recherche $query = "Select * from vu_affect_empl "; if (!empty($_POST["query"])) { $search = mysqli_real_escape_string($connect, $_POST["query"]); $query .= "WHERE USER_ID LIKE '"; $query .= $search; $query .= "%' OR USER_ID LIKE '"; $query .= $search; $query .= "%' OR Num_SIM LIKE '"; $query .= $search; $query .= "%' ORDER BY Nom asc"; } else { $query .= "ORDER BY USER_ID"; } //Lancement de la requete $result = mysqli_query($connect, $query); } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> </head> <body> <?php if(isset($result) && mysqli_num_rows($result) > 0) { ?> <div class="table-responsive"> <table class="table table bordered"> <tr onclick="SelectLigne(this)"> <td> </td> <th>USER ID</th> <th>Nom</th> <th>Prenom</th> <th>Num SIM</th> <th>PIN Terminal</th> <th>PIN SIM</th> <th>Num EMEI</th> <th>Date Debut</th> <th>Date Fin</th> <th>Vitre</th> <th>Coque</th> <th>Support Vehicule</th> <th>Actif</th> <th>Or Affectation1</th> <th>Statut</th> </tr> <?php while($row = mysqli_fetch_array($result)) { ?> <tr> <td><input type="checkbox" name="Select[]" value="<?php echo $row['USER_ID'];?>" class="Selection"> </td> <td><?php echo $row["USER_ID"]; ?></td> <td><?php echo $row["Nom"]; ?></td> <td><?php echo $row["Prenom"]; ?></td> <td><?php echo $row["Num_SIM"]; ?></td> <td><?php echo $row["PIN_Terminal"]; ?></td> <td><?php echo $row["PIN_SIM"]; ?></td> <td><?php echo $row["Num_IMEI"]; ?></td> <td><?php echo $row["Date_Debut"]; ?></td> <td><?php echo $row["Date_Fin"]; ?></td> <td><?php echo $row["Vitre"]; ?></td> <td><?php echo $row["Coque"]; ?></td> <td><?php echo $row["Support_Vehicule"]; ?></td> <td><?php echo $row["Actif"]; ?></td> <td><?php echo $row["Or_Affectation1"]; ?></td> <td><?php echo $row["Statut"]; ?></td> </tr> <?php } } else { echo 'Pas enregistrement pour le moment'; } ?> </body> </html>
et le sql
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 function CustomAlert(){ this.render = function(dialog){ var winW = window.innerWidth; var winH = window.innerHeight; var dialogoverlay = document.getElementById('dialogoverlay'); var dialogbox = document.getElementById('dialogbox'); dialogoverlay.style.display = "block"; dialogoverlay.style.height = winH+"px"; dialogbox.style.left = (winW/2) - (550 * .5)+"px"; dialogbox.style.top = "100px"; dialogbox.style.display = "block"; document.getElementById('dialogboxhead').innerHTML = "Acknowledge This Message"; document.getElementById('dialogboxbody').innerHTML = dialog; document.getElementById('dialogboxfoot').innerHTML = '<button onclick="Alert.ok()">OK</button>'; } this.ok = function(){ document.getElementById('dialogbox').style.display = "none"; document.getElementById('dialogoverlay').style.display = "none"; } } var Alert = new CustomAlert(); function deletePost(id){ var db_id = id.replace("post_", ""); // Run Ajax request here to delete post from database document.body.removeChild(document.getElementById(id)); } function CustomConfirm(){ this.render = function(dialog,op,id){ var winW = window.innerWidth; var winH = window.innerHeight; var dialogoverlay = document.getElementById('dialogoverlay'); var dialogbox = document.getElementById('dialogbox'); dialogoverlay.style.display = "block"; dialogoverlay.style.height = winH+"px"; dialogbox.style.left = (winW/2) - (550 * .5)+"px"; dialogbox.style.top = "100px"; dialogbox.style.display = "block"; document.getElementById('dialogboxhead').innerHTML = "Est-ce que le matériel est déjà retourné ?"; document.getElementById('dialogboxfoot').innerHTML = '<button onclick="Confirm.yes(\''+op+'\',\''+id+'\')">Oui</button><button onclick="Confirm.no()">Non</button>'; } this.no = function(){ document.getElementById('dialogbox').style.display = "none"; document.getElementById('dialogoverlay').style.display = "none"; } this.yes = function(op,id){ if(op == "delete_post"){ deletePost(id); } document.getElementById('dialogbox').style.display = "none"; document.getElementById('dialogoverlay').style.display = "none"; } } var Confirm = new CustomConfirm();
ps la requete vien de access
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 OuiNon = MsgBox("Est-ce que le matériel est déjà retourné ?", vbYesNo) If OuiNon = vbYes Then strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Non Affecté""" strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """ strmysql = strmysql & Numero_puce strmysql = strmysql & """);" ' DoCmd.RunSQL strmysql Me.Statut_Affectation = "Non Affecté" DoCmd.RunCommand acCmdSaveRecord MyDate = Date$ User = Environ("USERNAME") RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )" RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #" RunMySQL = RunMySQL & MyDate RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire, """ RunMySQL = RunMySQL & User RunMySQL = RunMySQL & """, #" RunMySQL = RunMySQL & MyDate RunMySQL = RunMySQL & "#, ""Supprimer Affectation""" RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";" DoCmd.RunSQL RunMySQL DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Non Affecté""" _ & " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'" ElseIf OuiNon = vbNo Then strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Attente Retour""" strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """ strmysql = strmysql & Numero_puce strmysql = strmysql & """);" ' DoCmd.RunSQL strmysql Me.Statut_Affectation = "Attente Retour" DoCmd.RunCommand acCmdSaveRecord MyDate = Date$ User = Environ("USERNAME") RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )" RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #" RunMySQL = RunMySQL & MyDate RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire,""" RunMySQL = RunMySQL & User RunMySQL = RunMySQL & """, #" RunMySQL = RunMySQL & MyDate RunMySQL = RunMySQL & "#, ""Supprimer Affectation - Attente Retour""" RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";" DoCmd.RunSQL RunMySQL DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Attente Retour""" _ & " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'"
merci
Si tu mets du code Access, c'est un peu normal que ça ne fonctionne pas.
peux tu m'aider a l'incorporé le sql dans ma page au moins me montrez comment s'y prendre s'il vous plais
Tu as déja eu des réponses ici :
https://www.developpez.net/forums/d1...requete-mysql/
et là :
https://www.developpez.net/forums/d1...requete-mysql/
Partager