Application de gestion des employés ب php و mysql الجزء الثالت
نظرة سريعة بالفيديو
1- الملف delete.php
<?php
include_once('database/connection.php');
$id = htmlentities($_GET['id']);
$query = "DELETE FROM employes WHERE id = '$id'";
if(mysqli_query($con,$query)){
header("location:index.php?deleted=Employé supprimé avec succés");
}else{
echo '<div class="alert alert-danger">Une erreur est survenue'.mysqli_error($con).'</div>';
}
?>
2- الملف search.php
<?php
include_once('includes/header.php');
?>
<div class="container">
<div class="form-group" style="padding:10px;">
<a href="add.php" class="btn btn-primary btn-sm pull-right">Ajouter</a>
</div>
<br>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<table class="table table-striped table-hover ">
<thead>
<tr class="info">
<th>Nom</th>
<th>Prénom</th>
<th>Matricule</th>
<th>Département</th>
<th>Salaire</th>
<th>Addresse</th>
<th>Ville</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$search = $_POST['search'];
$query = "SELECT * FROM employes WHERE nom='$search' or prenom='$search'";
$result = mysqli_query($con,$query);
while($row = $result->fetch_assoc()):
?>
<tr>
<td><?php echo $row['nom'];?></td>
<td><?php echo $row['prenom'];?></td>
<td><?php echo $row['matricule'];?></td>
<td><?php echo $row['dept'];?></td>
<td><?php echo $row['salaire'];?></td>
<td><?php echo $row['adresse'];?></td>
<td><?php echo $row['ville'];?></td>
<td><?php echo ($row['status']) ? '<span class="text-primary">Active</span>' : '<span class="text-danger">Débauché</span>';?></td>
<td><a href="update.php?id=<?php echo $row['id'];?>" class="btn btn-warning btn-xs"><i class="fa fa-pencil" title="Modifier"></i></a>|<a href="delete.php?id=<?php echo $row['id'];?>" class="btn btn-danger btn-xs" title="Supprimer"><i class="fa fa-trash"></i></a></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
include_once('includes/footer.php');
?>
3- الملف style.css
.error{
border: 1px solid red;
}
.well{
box-shadow: 0.5px 0.5px 0.5px 0.5px #000;
}
table{
box-shadow: 0.5px 0.5px 0.5px 0.5px #000;
}
body{
background:beige;
}
4- validate.js
$(document).ready(function(){
$('#submit').on('click',function(e){
var nom = $('#nom');
var prenom = $('#prenom');
var sal = $('#sal');
var mat = $('#mat');
var dept = $('#dept');
var city = $('#city');
var adress = $('#adress');
var fields = [nom,prenom,mat,sal,dept,adress,city];
for(var i=0;i<fields.length;i++){
if(fields[i].val() == ""){
e.preventDefault();
fields[i].addClass("error");
}
}
});
$('#searchSubmit').on('click',function(e){
var nom = $('#search');
if(nom.val() == ""){
e.preventDefault();
nom.addClass("error");
}
});
});