I am trying to develop a seach page to search the customer files that in the database. I want to be able to search and the result display on the same page and i can search for another customer without going to another page.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".search_button").click(function() {
// getting the value that user typed
var searchString = $("#search_box").val();
// forming the queryString
var data = 'search='+ searchString;
// if searchString is not empty
if(searchString) {
// ajax call
$.ajax({
type: "POST",
url: "getdev.php",
data: data,
beforeSend: function(html) { // this happens before actual call
$("#results").html('');
$("#searchresults").show();
$(".word").html(searchString);
},
success: function(html){ // this happens after we get results
$("#results").show();
$("#results").append(html);
}
});
}
return false;
});
});
</script>
</head>
<body>
<?php include('header.html.php'); ?>
<div id="content">
<div id="columnC">
<h2>Search Customers</h2>
<form method="post" action="getdev.php">
<input type="text" name="search" id="search_box" class='search_box'/>
<input type="submit" value="Search" class="search_button" /><br />
</form>
<div id="searchresults">Search results :</div>
</div>
</div>
so this is php file
<?php
//if we got something through $_POST
if (isset($_POST['search'])) {
// here you would normally include some database connection
include('connect.php');
// $db = new db();
// never trust what user wrote! We must ALWAYS sanitize user input
$word = mysql_real_escape_string($_POST['search']);
$word = htmlentities($word);
// build your search query to the database
$q = "SELECT custid, cdate, custName, address1, address2, phone, cellphone, email, equipment, manufacturer, model, serial, imei, notes, priority FROM customer WHERE custid='$word' OR custName like '$word' ORDER BY equipment ASC ";
$result = @mysqli_query ($dbcon, $q); // Run the query.
if ($result) { // If it ran, display the records.
// Table header.
echo '<table id="result"> <tr>
<th><b>Edit</b></th>
<th><b>Delete</b></th>
<th><b>ID</b></th>
<th><b>Date</b></th>
<th><b>Name</b></th>
<th><b>Address</b></th>
<th><b>Address </b></th>
<th><b>Phone </b></th>
<th><b>Cellphone </b></th>
<th><b>Email</b></th>
<th><b>Equipment</b></th>
<th><b>Manufacturer</b></th>
<th><b>Modell</b></th>
<th><b>Serial</b></th>
<th><b>IMEI</b></th>
<th><b>Notes</b></th>
<th><b>Priority</b></th>
</tr>';
} else {
echo '<li>No results found</li>';
}
}
?>
I am not getting any result on the page at all. Any help or link to an example would be lovely