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 119 120 121 122 123 124 125 126 127 128
|
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<title>Etat des commandes</title>
</head>
<body>
<?php
$con = mysqli_connect('localhost', 'root', '', 'onoffpc');
//On determine l'expression a rechercher
if(isset($_POST['recherche']))
{
$rec = htmlentities($_POST['recherche']);
}
else
{
$rec = 'attente cours';
}
//On determine le type de recherche
if(isset($_POST['type']))
{
if($_POST['type']=='un')//Un des mots
{
$type = 1;
}
else//Tout les mots
{
$type = 2;
}
}
else
{
$type = 1;//type par defaut: L'expression exacte
}
//On determine si on doit surligner les mots dans les resultats
if(!isset($_POST['surligner']) or $_POST['surligner']!='true')
{
$surligner = false;
}
else
{
$surligner = true;
}
//On determine les identifiants, les noms et les informations des utilisateur
$req = 'SELECT id, etatid, etat, codeclient, codeproclient, materiel, accessoire, marque, modele, clelicense FROM depot WHERE ';
if($type==1)
{//ayant un des mots dans leurs informations
$mots = explode(' ',$rec);//En separe lexpression en mots cles
foreach($mots as $mot)
{
$req .= 'etat LIKE "%'.$mot.'%" OR ';
}
$req .= ' 1=0';
}
elseif($type==2)
{//ayant tout des mots dans leurs informations
$mots = explode(' ',$rec);//En separe l'expression en mots cles
foreach($mots as $mot)
{
$req .= 'etat LIKE "%'.$mot.'%" AND';
}
$req .= ' 1=1';
}
//Les utilisateur seront ranges par identifiant en ordre croissant
$req .= ' order by etatid asc';
$requete = mysqli_query($con,$req);
?>
<form action="" method="post">
<input type="HIDDEN" name="recherche" value="<?php echo $rec; ?>" />
<input type="HIDDEN" name="type" value="un"<?php if($type==1){echo 'checked="checked"';} ?> />
<input type="HIDDEN" name="type" value="tout"<?php if($type==2){echo 'checked="checked"';} ?> />
<input type="HIDDEN" name="surligner" value="true" checked="yes"<?php if($surligner){echo 'checked="checked"';} ?> />
<input type="HIDDEN" value="Rechercher" />
</form>
<h2>Etat des commandes :</h2>
<table border>
<tr>
<th>Identifiant</th>
<th>Etat</th>
<th>Code client</th>
<th>Code proclient</th>
<th>Matériel</th>
<th>Accessoire</th>
<th>Marque</th>
<th>Modéle</th>
<th>Lien vers la fiche</th>
</tr>
<?php
//On affiche les resultats
while($dn = mysqli_fetch_array($requete))
{
?>
<tr>
<td><?php echo $dn['id']; ?></td>
<td><?php
if($surligner)//Si il faut surligner les mots, on les surligne
{
if($type==3)
{
echo preg_replace('#('.preg_quote($rec).')#i', '<strong>$1</strong>', $dn['etat']);//On surligne l'expression exacte
}
else
{
echo preg_replace('#('.str_replace(' ','|',preg_quote($rec)).')#i', '<strong>$1</strong>', $dn['etat']);//On surligne les mots cles de la recherche
}
}
else
{
echo $dn['etat'];//On ne surligne pas
}
?></td>
<td><?php echo $dn['codeclient']; ?></td>
<td><?php echo $dn['codeproclient']; ?></td>
<td><?php echo $dn['materiel']; ?></td>
<td><?php echo $dn['accessoire']; ?></td>
<td><?php echo $dn['marque']; ?></td>
<td><?php echo $dn['modele']; ?></td>
<td><a href="pagefiche.php" target="_blank"> <input type="button" value="Visionner"> </a> </td>
</tr>
<?php
}
?>
</table>
</body>
</html> |
Partager