Bonjour,

j'essaie de créer un moteur de recherche pour ma base. Ci-joint mon code :
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
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
 
<html lang="fr">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
 
<title>RECHERCHE</title>
 
</head>
 
<body>
 
<form action="" method="POST" enctype="application/x-www-form-urlencoded">
 
<fieldset>
<legend><b>Rechercher un dossier</b></legend>
 
<table>
<tbody>
<tr>
<td> Affaire : </td>
<td><input type="text" name="AFFAIRE" size="40" maxlength="40"/></td>
</tr>
 
<tr><td>
<select name="CA">
<option value="tous">tous</option>
<option value="ABDA">ABDA</option>
</select>
</td></tr>
 
<tr><td><input type="submit" value="RECHERCHER" /></td></tr>
 
</tbody>
</table>
</fieldset>
</form>
 
<?php
 
if(!empty($_POST['AFFAIRE']))
{
include('connect.php');
$idcom=connexobjet('magasin','myparam');
 
$AFFAIRE=strtolower(($_POST['AFFAIRE']));
$CA=$_POST['CA'];
 
$reqCA=($_POST['CA']=="tous")?"":"AND CA='$CA'";
$requete="SELECT AFFAIRE,CA,AMEO FROM client WHERE lower(AFFAIRE) LIKE lower('%AFFAIRE%')".$reqCA." ORDER BY AFFAIRE";
$result=$idcom->query($requete);
 
if(!$result)
{
echo "Lecture impossible";
}
else
{
$nbcol=$result->field_count;
$nbart=$result->num_rows;
$titres=$result->fetch_fields();
echo "il y a $nbart dossiers correspondants au critère choisi : $AFFAIRE";
 
echo "<table><tr>";
 
foreach($titres as $nomcol=>$val)
{
echo "<th>", $titres[$nomcol]->name,"</th>";
}
 
echo "<tr>";
 
for($i=0;$i<$nbart;$i++)
{
$ligne=$result->fetch_row();
 
echo "<tr>";
 
for($j=0;$j>$nbcol;$j++)
{
echo "<td>",$ligne[$j],"</td>";
}
echo "</tr>";
}
 
echo "</table>";
 
$result->free();
$idcom->close();
}
}
 
?>
 
</body>
</html>
En résultat j'obtiens :

Nom : Capture.PNG
Affichages : 2547
Taille : 7,3 Ko

Il ne trouve pas le dossier alors que celui-ci existe bien dans la base.

Merci de votre aide.