I have a connection to a database, and have created a dynamic table with Dreamweaver; that all is fine. Now I am trying to make a live search with Java, with the searchbox in the table, and java reuiers to show the data in divs. The results appear on another table, although I didn't write anything inside the div, and my table doesn't change. Now I need to make the actions on the table itself, or to make that table be that div function.
Can someone help me to get the results on the same table or give me an example of how to do it? My code is the following:
<?php require_once('Connections/localhost.php'); ?>
<?php
mysql_select_db($database_localhost, $localhost);
if (isset($_POST['Searchbox'])) {
$search = $_POST['Searchbox'];
$searchresult = mysql_query("SELECT * FROM members WHERE company LIKE '%".$search."%' or country LIKE '%".$search."%'or adresse LIKE '%".$search."%'or prcontact LIKE '%".$search."%'or tel LIKE '%".$search."%'or email LIKE '%".$search."%'or website LIKE '%".$search."%'");
if (mysql_num_rows($searchresult) > 0){
while ($searcharray = mysql_fetch_array($searchresult)) {
$query_members = "SELECT * FROM members WHERE company LIKE '%".$search."%' or country LIKE '%".$search."%'or adresse LIKE '%".$search."%'or prcontact LIKE '%".$search."%'or tel LIKE '%".$search."%'or email LIKE '%".$search."%'or website LIKE '%".$search."%'";
}
}
else {
$query_members = "SELECT details, company, country, adresse, prcontact, tel, email, website FROM members";
}
}
$query_limit_members = sprintf("%s LIMIT %d, %d",
$query_members, $startRow_members, $maxRows_members);
$members = mysql_query($query_limit_members, $localhost) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" >
function getSearch(value) {
$.post("?", {Searchbox:value},function(data) {
$("#results").html(data)
});
}
</script>
<body>
<table border="1" align="center">
<tr>
<td colspan="8"><form action="" method="POST" name="search"><input name="search_box1" type="text" id="search_box1" placeholder="Search" size="100" onkeyup="getSearch(this.value)" formaction="" /></form></td>
</tr>
<tr align="center" valign="middle">
<td><strong>Details</strong></td>
<td><strong>Company</strong></td>
<td><strong>Country</strong></td>
<td><strong>Adress</strong></td>
<td><strong>PreContact</strong></td>
<td><strong>Telefon</strong></td>
<td><strong>E-Mail</strong></td>
<td><strong>Website</strong></td>
</tr>
<tr>
<td> </td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box2" id="search_box2" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box3" id="search_box3" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box4" id="search_box4" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box5" id="search_box5" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box6" id="search_box6" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box7" id="search_box7" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box8" id="search_box8" formaction="" /></form></td>
</tr>
<?php do { ?>
<tr align="center" valign="middle">
<td><img src="<?php echo $row_members['details']; ?>" width="120" height="32" /></td>
<td><?php echo $row_members['company']; ?></td>
<td><?php echo $row_members['country']; ?></td>
</tr>
<?php } while ($row_members = mysql_fetch_assoc($members)); ?>
</table>
<p> </p>
<p> </p>
<p> </p>
<div id="results"></div>
</body>