<link rel="stylesheet" href="strona.css" type="text/css"/> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" type="text/css" href="tcal.css" /> <script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script>
<form name="sprzedawca" method="POST" action="dane.php" enctype="multipart/form-data" autocomplete="off" > <th colspan="2">dokument
</th>
<div><input type="text" name="data" class="tcal" value="" /></div>
<input type="text" class="search_keyword" id="search_keyword_id" name="klient" />
<script type="text/javascript"> $(function(){
$(".search_keyword").keyup(function()
{
var search_keyword_value = $(this).val();
var dataString = 'search_keyword='+ search_keyword_value;
if(search_keyword_value!='')
{
$.ajax({
type: "POST",
url: "search.php",
data: dataString,
cache: false,
success: function(html)
{
$("#result").html(html).show();
}
});
}
return false;
});
$("#result").live("click",function(e){
var $clicked = $(e.target);
var $name = $clicked.find('.country_name').html();
var decoded = $("
<div/>").html($name).text();
$('#search_keyword_id').val(decoded);
});
$(document).live("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search_keyword")){
$("#result").fadeOut();
}
});
$('#search_keyword_id').click(function(){
$("#result").fadeIn();
});
});
plik search.php
<?php
include('/db.php');
if(isset($_POST['search_keyword'])) {
$search_keyword = $polaczenie->real_escape_string($_POST['search_keyword']);
$sqlCountries="SELECT nazwa FROM sklep WHERE nazwa LIKE '%$search_keyword%'";
$resCountries=$polaczenie->query($sqlCountries);
if($resCountries === false) {
}else{
$rows_returned = $resCountries->num_rows;
}
$bold_search_keyword = '<strong>'.$search_keyword.'</strong>';
if($rows_returned > 0){
while($rowCountries = $resCountries->fetch_assoc())
{
echo '<div class="show" align="left"><span class="country_name">'.str_ireplace
($search_keyword,$bold_search_keyword,$rowCountries['nazwa']).'</span></div>'; }
}else{
echo '<div class="show" align="left">Brak</div>'; }
}
?>
Ten post edytował lkjhgf345 2.01.2017, 15:05:41