Answer the question
In order to leave comments, you need to log in
ajax php sql form?
Good day, there is a form
<form method="post" action="search_ajax.php">
<input type="text" class="search_input" name="search" id="search" class='search_box'/>
<select class="search_in" name="search_in" id="search_in">
<option value='' selected='selected'>Искать по</option>
<option VALUE="id">Номер</option>
<option VALUE='status'>Статус</option>
<option VALUE='master'>Мастер</option>
</select>
<input type="submit" value="Поиск" class="search_button" /><br />
</form>
if (isset($_POST['search_in'])) {
$s_i = $_POST['search_in'];
echo $s_i;
}
if (isset($_POST['search'])) {
$s = $_POST['search'];
echo $s;
}
$query_to_db = mysql_query("SELECT * FROM equipment WHERE $s_i LIKE '%$s%'");
<script type="text/javascript">
$(function(){
$("#search").keyup(function(){
var search = $("#search").val();
$.ajax({
type: "POST",
url: "search_ajax.php",
data: {"search": search},
cache: false,
success: function(response){
$("#resSearch").html(response);
}
});
return false;
});
});
</script>
<script type="text/javascript">
$(function(){
$("#search_in").change(function(){
$.ajax({
type : 'POST',
url : 'search_ajax.php',
data : { search_in: $(this).val() },
success: function(response){
$("#resSearch").html(response);
}
});
})
}
);
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question