i need help with append row/s to table selected from database.
i have index.php with form:
<form action="" id="pos_data" method="post">
<input type="text" name="typeSearch" placeholder="Enter Type Number to Search" /><br/><!-- comment -->
<input type="submit" name="searchbtn" value="Search Data">
</form>
<?php
require_once 'db.php';
require_once 'load_table.php';
echo'<div id="refresh_table"></div><br/>';
?>
and i have load_table.php (show data from database to table):
<?php
include 'db.php'; //other file with conn to database
$query = "Select....."; //10 rows
$result = sqlsrv_query($dbhandle, $query)
or die('A error occured: ' . mysql_error()); //$dbhandle define in db.php
$o = '<table id="myTable">
<thead>
<tr>
<th>TYPE </th>
<th>Line</th>
<th>Free Space </th>
<tbody></tbody>
</tr>
</thead><tbody>';
while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)){
$o .= '<tr><td>'.$row ['MATNR'].'</td> <td>'.$row ['NLPLA'].'</td> <td>'.$row ['freeSpace'].'</td> </tr>';
}
$o .= '</tbody></table>';
echo $o;
sqlsrv_free_stmt($result);
sqlsrv_close($dbhandle);
?>
It works well. The table appears and next to the table there is a bar with a button.
And I would like when I write something in the search field, it will search for it again in the DB (according to the given query) and add a row / rows to the original table. He tried this in another file search_load.php:
<?php
include 'db.php';
include 'load_table.php';
if(isset($_POST['searchbtn']))
{
$typeNumber = $_POST['typeSearch'];
$querySearch = "Select ..... WHERE MATNR LIKE '%".$typeNumber."%'";
$resultSearch = sqlsrv_query($dbhandle, $querySearch)
But I don't know how to attach it to the original table. Actually, I don't know if it can work like this. If not, how could it work?