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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
<?php
include 'connect.inc.php';
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#recherche").keyup(function(){
var recherche = $(this).val();
var data = 'motclef=' + recherche;
if(recherche.length>2){
$.ajax({
type : "GET",
url : "result.php",
data : data,
success: function(server_response){
$("#resultat").html(server_response).show();
}
});
}
});
});
</script>
<form method="get" action="recherche.php">
<input type="text" name="recherche" id="recherche" value="<?php if (isset($_GET['recherche'])){echo $_GET['recherche'];} ?>" />
<button id="two" type="submit" value="SEARCH" >SEARCH</button>
<br />
<div class="resultat" id="resultat"></div>
</form>
<?php
echo '<table>
<tr>
<td><strong>art</strong></td>
<td><strong>Ref </strong></td>
<td><strong>Classe</strong></td>
<td><strong>Descrip</strong></td>
<td><strong>Pack</strong></td>
<td><strong>prix</strong></td>
</tr>';
if (isset ($_GET['recherche'])){
$recherche=$_GET['recherche'];
$s=explode(" ",$recherche);
mysql_connect("localhost","root","");
mysql_select_db("bdd");
$sql="SELECT * FROM table";
$tabWhere = array();
foreach ($s as $mot)
if(strlen($mot)>3)
$tabWhere[] = "fourni LIKE '$mot%'";
if(sizeof($tabWhere) > 0)
{
$sql .= ' WHERE '.implode(' OR ', $tabWhere);
$req=mysql_query($sql) or die( mysql_error());
echo'<br /><br /><br /><br />';
echo '<p>'.mysql_num_rows($req).' reponse : '.$_GET['recherche'].'<br />';
while($d=mysql_fetch_assoc ($req)){
$c=$d['fourni'];
$i=0;
foreach ($s as $mot) {
if(strlen($mot)>3){
$i++;
if($i>4){$i=1;}
$c = str_ireplace($mot,'<span class="surligne'.$i.'">'.$mot.'</span>',$c);
}
}
echo '<tr><td id="art">'.stripslashes($d['art']).'</td>';
echo '<td id="titri">'.stripslashes($d['titri'])."</td>";
echo '<td id="classi">'.stripslashes($d['classi'])."</td>";
$art = $d['art'];
$fourni = $d['fourni'];
$sql3 ="SELECT ref,code_art FROM prod where code_art = '".$art."'";
$req3=mysql_query($sql3) or die( mysql_error());
while ($data3 = mysql_fetch_assoc($req3)){
$ref = $data3['ref'];
$code_art = $data3['code_art'];
}
$sql2 = "SELECT *
FROM table,prod
where table.art = '".$art."'
AND prod.ref = '".$ref."'
AND table.fourni = '".$fourni."' ";
$req2=mysql_query($sql2) or die( mysql_error());
while ($data2 = mysql_fetch_assoc($req2)){
if ($code_art === null) {
}else {
echo '<td>'.stripslashes($data2['name'])."</td>";
}
if ($code_art === null) {
}else {
echo '<td>'.stripslashes($data2['cond'])."</td>";
}
}
?>
<td align="left" valign=top>
<?php
$lien = $d['art'];
echo "<a href='lien.php?search=$lien' target='_blank'>prix</a>";
echo'<br /><br />';
}
}else
echo'<br /><br />';
}
else {
echo'<br /><br />';
echo "Keywords must have more than three letters";
}
?>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="jquery.buttonLoader.js"></script>
<script>
$(document).ready(function () {
$('.has-spinner').click(function () {
var btn = $(this);
$(btn).buttonLoader('start');
setTimeout(function () {
$(btn).buttonLoader('stop');
}, 3000);
});
});
</script> |
Partager