Exécution requête sur bouton
Bonjour, j'ai un petit soucis de requete mysql je m'explique j'aimerais mettre a jour la colonne "statut" via un checkbox en cliquant sur un bouton mais lorsque je clique sur le bouton rien se passe.
je voudrais savoir si mon code est bon
requette.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
$servername = "localhost";
$username = "root";
$password = "Mm101010";
$dbname = "smartphone";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
$data_ids = $_REQUEST['data_ids'];
$data_id_array = explode(",", $data_ids);
if(!empty($data_id_array)) {
foreach($data_id_array as $Or_Affectation) {
$sql = "UPDATE abonnements SET Statut_Abo = "Non Affecté" ";
$sql.=" WHERE Or_Affectation = '".$Or_Affectation."'";
$query=mysqli_query($conn, $sql) or die("supr_Affect.php: Suprimer Affectation");
}
}
?> |
index.php
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
| <!DOCTYPE html>
<html>
<title>Smartphone</title>
<head>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="css/bouton.css">
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" >
$(document).ready(function() {
var dataTable = $('#vu_affect_empl').DataTable( {
"processing": true,
"serverSide": true,
"columnDefs": [ {
"targets": 0,
"orderable": false,
"searchable": false
} ],
"ajax":{
url :"Affectation.php", // json datasource
type: "post", // method , by default get
error: function(){ // error handling
$(".vu_affect_empl-error").html("");
$("#vu_affect_empl").append('<tbody class="vu_affect_empl-error"><tr><th colspan="3"></th></tr></tbody>');
$("#vu_affect_empl_processing").css("display","none");
}
}
} );
$("#action_ligne").on('click',function() { // bulk checked
var status = this.checked;
$(".updateRow").each( function() {
$(this).prop("checked",status);
});
});
$('#update_affect').on("click", function(event){ // triggering delete one by one
if( $('.updateRow:checked').length > 0 ){ // at-least one checkbox checked
var ids = [];
$('.updateRow').each(function(){
if($(this).is(':checked')) {
ids.push($(this).val());
}
});
var ids_string = ids.toString(); // array to string conversion
$.ajax({
type: "POST",
url: "supr_Affect.php",
data: {data_ids:ids_string},
success: function(result) {
dataTable.draw(); // redrawing datatable
},
async:false
});
}
});
} );
</script>
<style>
div.container {
margin: 0 auto;
max-width:760px;
}
div.header {
margin: 100px auto;
line-height:30px;
max-width:760px;
}
body {
background: #f7f7f7;
color: #333;
font: 90%/1.45em "Helvetica Neue",HelveticaNeue,Verdana,Arial,Helvetica,sans-serif;
} </style>
</head>
<body>
<h2 align="center">Affectation</h2><br/><br/><br/>
<center>
<button href="Abonnement.php" id="update_affect" class="bouton_dans_page">Abonnement</button>
<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>
<table id="vu_affect_empl" cellpadding="0" cellspacing="0" border="0" class="display" width="100%"><br/><br/><br/><br/>
<thead>
<tr>
<th><input type="checkbox" id='action_ligne' /></th>
<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>Statut</th>
</tr>
</thead>
</table><br><br>
<button type="button" class="Menu" id="update_affect" name="Supprimer_affect">Suprimer Affectation</button>
<button class="Menu" type="button" id="C_R_E" onclick="javascript:Confirmer" name="C_R_E">Confirmer Retour Equipement</button>
<a href="Equipement_Modal.php" class="Menu" id="R_E" name="R_E"> Remplacer Equipement</a>
<button class="Menu" type="button" id="A_S_L" name="A_S_L">Ajout et Supression Ligne</button>
<button class="Menu" type="button" id="C_R_A" name="C_R_A">Confirmer Retour Abonnement</button>
<button class="Menu" type="button" id="Reaff_Equip" name="Reaff_Equip">Reaffectation Equipement</button>
</center>
</body>
</html> |
Merci