Eléphant du PHP |
58 Messages
12 déc. 2013, 23:25
Bonsoir moogli,
j'ai fait les pages ajouter, afficher la liste des clients,
mais je ne sais pas quelle code pour faire une recherche avec LIKE.
Car le mot entré dans l'imput de la recherche ne passe pas par le il et va directement dans le else.
je te joint le fichier recherche
<?php
include('../config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>scoreboard</title>
<link href="Css/style.css" type="text/css" rel="stylesheet"/>
<link href="Css/menuPage.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div id="global">
<div id="headerMenu">
<div id="logo">
<img src="../images/logo.jpg" width="100" height="56">
<?php include_once'menuPage.php';?>
</div><!-- end div logo-->
</div><!-- end headerMenu -->
<div id="principale">
<form method="POST" action="function_search.php">
<center>
Rechercher
<input type="text" name="search" />
<select name="search_list">
<option value="dossier" selected="dossier">dossier</option>
<option value="type_societe" selected="type_societe">type_societe</option>
<option value="tache" selected="tache">tâche</option>
<option value="commentaire" selected="commentaire">commentaire</option>
<option value="" selected=""></option>
</select>
<p>
<input type="submit" name="submit" value="Chercher" />
</center></p>
</form>
<!-- fin du texte -->
<div class="foot">
<?php include('footerPage.php');?>
</div>
</div><!-- end div pricipale-->
</div><!-- end div global-->
</body>
</html>
et le fichier action
<?php
include('../config.php');
if($_POST['search_list']=='nom_dossier')
{
$search=$_POST['search'];
?>
<table width ='100%'>
<tr>
<td><b>nom_dossier</b></td>
<td> </td>
<td><b>type_societe</b></td>
<td> </td>
<td><b>collaborateur</b></td>
<td> </td>
<td><b>date_cloture</b></td>
<td> </td>
<td><b>type_mission</b></td>
<td> </td>
<td><b>tâche</b></td>
<td> </td>
<td><b>périodicité</b></td>
<td> </td>
<td><b>date_échéance</b></td>
<td> </td>
<td><b>quantité</b></td>
<td> </td>
<td><b>avancement</b></td>
<td> </td>
<td><b>commentaire</b></td>
</tr>
<?php
$req = "select * FROM excel WHERE nom_dossier LIKE '%.$search%' ";
$result_set=mysql_query($req);
while($dnn = mysql_fetch_array($result_set))
{
?>
<tr>
<td class="left">
<?php echo htmlentities($dnn['nom_dossier'], ENT_QUOTES, 'UTF-8'); ?>
</a></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['type_societe'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['collaborateur'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['date_cloture'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['type_mission'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['tache'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['periodicite'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['date_echeance'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['quantite'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['avancement'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td class="left"><?php echo htmlentities($dnn['commentaire'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> </td>
<td>
<a href="afficher.php?id=<?php echo $dnn['id']; ?>">Modifier</a>
</td>
</tr>
<?php
}
}
else
{
echo'Aucune correspondance avec votre recherche';
}
?>
MERCI
On n'a le droit de ne pas savoir mais on n'a pas le droit de ne pas demander.
Ubuntu Php Mysql