Am scripturile acestea:
javascript
Cod: Selectaţi tot
<script type="text/javascript">
function lookup(inputString) {
if(inputString.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("cautare.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup
</script>
Cod: Selectaţi tot
<?php
$db = new mysqli('localhost', 'root' ,'', 'bd');
if(!$db) {
echo 'Nu se poate conecta la Baza de date!';
} else {
if(isset($_POST['queryString'])) {
$queryString = $db->real_escape_string($_POST['queryString']);
if(strlen($queryString) >0) {
$categoria = 'c';
//echo $categoria;
$query = $db->query("SELECT * FROM cantari_ppt WHERE categoria='".$categoria."' AND aprobare = 1 AND denumire LIKE '$queryString%' ORDER BY denumire LIMIT 10");
if($query) {
while ($result = $query ->fetch_object()) {
//echo ''.$result->denumire.'<br>';
if ($result->categoria == 'c')
{
echo '<span class="d"><img src="powerpoint_icon.png" width="24" height="24"> <a href="localhost/cautare/index.php?urlf='.$result->urlf.'">'.$result->denumire.'</a> </span> ~ copii<br>';
}
elseif ($result->categoria == 'co')
{
echo '<span class="d"><img src="powerpoint_icon.png" width="24" height="24"> <a href="localhost/cautare/index.php?urlf='.$result->urlf.'">'.$result->denumire.'</a> </span> ~ colinde<br>';
}
}
} else {
echo 'A aparut o problema. nu este query';
}
} else {
}
}
else {
echo 'Nu s-a trimis nimic de la index!';
}
}
?>
Cod: Selectaţi tot
<form id="search" name="search">
<input type="text" size="50" name="term" value="" placeholder="Scrie numele cantarii" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
</form> <br><br>
<div class="suggestionsBox" id="suggestions" style="display: none;">
<div class="suggestionList" id="autoSuggestionsList">
</div>
</div>
Cod: Selectaţi tot
<form method="post" action="" id="frms">
<input type="radio" name="rbtn" value="" onclick="this.form.submit()">Toate
<input type="radio" name="rbtn" value="c" onclick="this.form.submit()">Copii
<input type="radio" name="rbtn" value="co" onclick="this.form.submit()">Colinde
</form>
ca atunci cand dau pe un buton radio sa imi ramana bifat si sa imi caute doar in sectiunea respectiva.
iar daca dau pe butonul "toate" sa nu tina cont de nimic ci sa caute in toate categoriile.
codul merge dar numai daca pun eu in cautare.php
Cod: Selectaţi tot
$categoria = 'c';
Sper ca ati inteles. astept raspuns. multumesc anticipat.
Cu stima trif.