<html>
<head>
<script type="text/javascript" src="jquery-3.0.0.min.js"></script>
</head>
<body>
<form method="POST">
<input type="text" class="form-control" placeholder="Search" name ="searchterm">
<a href="#" id="button"><button type="submit" id="submit">click me</button></a>
</form>
<script>
$(document).ready(function(){
$("#button").click(function(){
$.get("search.php");
return false;
});
});
</script>
</body>
</html>
above is the html file of my code search.html
<?php
mysql_connect("localhost","root","");
mysql_select_db("testdb");
$search = mysql_real_escape_string(trim($_POST['searchterm']));
$find_categories = mysql_query("SELECT `person3`,`person4` FROM `dbtable` WHERE `person1` LIKE'%$search%'");
$data = array();
while($row = mysql_fetch_assoc($find_categories))
{
$data[]=$row;
}
echo json_encode($data);
?>
and this is my php file search.php
I am having problem in fetching data from my database and displaying it. How can i do it and is there any way so that i can display it on a popup?