hi all, i have search form that retrieves data from database. and i have select options. when i choose with only
select option
it can populate data from database. but i want to retrieve data from database with both input tag (by typing into it) and select tag it cannot select any data from database
my web page address is below.
http://rabotnik.karyeram.com
my do_search.php file is
<?php
//if we got something through $_POST
if (isset($_POST['search']) || isset($_POST['axtaris'])) {
// here you would normally include some database connection
include("config/connect.php");
$db=new funksiyalar('karyeram');
// $db = new db();
// never trust what user wrote! We must ALWAYS sanitize user input
$word = mysql_real_escape_string($_POST['search']);
$cat=mysql_real_escape_string($_POST['category']);
// build your search query to the database
// if($cat==""){
// $sql = "SELECT id, seher, mezmun, place, subyekt, date, sekil from jobs WHERE subyekt LIKE '%" . $word . "%' ORDER BY id LIMIT 10";
// }
// get results
if(!$cat=="") {
$sql = "SELECT id, seher, mezmun, place, subyekt, date, sekil from jobs WHERE mezmun='$cat'";
}
$row = $db->query($sql);
if(count($row)) {
$end_result = '';
echo '<table width="840px">
<tr id="basliq"><td id="basliq1">Şəhər</td><td id="basliq2">Vəzifənin adi</td><td id="basliq3">Sahə</td><td id="basliq4">İş yeri</td><td id="basliq5">Tarix</td></tr>';
foreach($row as $r) {
$result=$r['mezmun'];
$result2=$r['seher'];
$result1=$r['subyekt'];
$result3=$r['place'];
$result4=$r['id'];
// we will use this to bold the search word in result
$bold = '<span class="found">' . $word . '</span>';
$end_result .= "<tr><td id=\"xana0\">" . str_ireplace($word, $bold, $result2) . "</td><td id=\"xana1\"><a href=\"index.php?id=$result4\">" . str_ireplace($word, $bold, $result1) . "</a></td><td id=\"xana1\">" . str_ireplace($word, $bold, $result) . "</td><td id=\"xana1\">" . str_ireplace($word, $bold, $result3) . "</td><td id=\"xana1\"/td></tr>";
}
echo $end_result;
echo '</table>';
} else {
echo '<li>No results found</li>';
}
}
?>
and my ajax (jquery) code is
$(function() {
$(".search_button").click(function() {
// getting the value that user typed
var searchString = $("#search_box").val();
var category = $('select[name=mezmun]').val();
// forming the queryString
var data = {'search' : 'searchString' , 'category' : category};
// if searchString is not empty
// ajax call
$.ajax({
type: "POST",
url: "do_search.php",
data: data,
beforeSend: function(html) { // this happens before actual call
$("#results").html('');
$(".word").html(searchString);
},
success: function(html){ // this happens after we get results
$('#gizli').html("") .hide();
$("#searchresults").show();
$("#results").show();
$("#results").append(html);
}
});
return false;
});
});
</script>
</head>
<body OnKeyPress="return disableEnterKey(event)">
<div id="butun">
<div id="banner">
</div>
<div id="menu">
<div id="container" style="margin-left:6px;">
<div style="margin-right:5px;">
<form method="post" action="do_search.php">
<input type="text" name="search" id="search_box" class='search_box'/><select name="mezmun" class="search_box1">
<option default value=""></option>
<option name="kend" value="Kənd təsərrüfatı">kend teserrufati</option>
<option name="Sumqayıt" value="İT">İT</option>
<option name="Gəncə" value="İqtisadiyyat">İqtisadiyyat</option>
<option name="Lənkəran" value="Sənaye">Sənayə</option>
<option name="Sabirabad" value="Nəqliyyat">Nəqliyyat</option></select>
<input type="submit" value="Axtar" class="search_button" name="axtaris"/><br />
</form>
</div>
<div>
thanks for attention.
i will wait your responses