I was wondering if it is possible to query a database, and each time a submit button is clicked, it will add a new row to the table, instead of refreshing the page.
You see, what's happening is that when I run the query, it will add the row successfully, but when I run the query again, it will refresh the page, essentially only being able to add only one row at a time.
Basically, I want to be able to create a table which will add a product to the list each time I scan a barcode with a barcode scanner. As the user scans the code, the query will execute to grab the relevant data from the database, and display a row.
$barcode = $_POST["Barcode"];
$query = "Select * from products WHERE ProductBarcode = $barcode";
$result = $mysqli->query($query);
if ($result->num_rows > 0) {
echo "<table>
<tr>
<td><strong>ID</strong></td>
<td><strong>Name</strong></td>
</tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td><input type='checkbox' value='".$row['Row_ID']."' />".$row['Row_ID']."</td>
<td>".$row['ProductName']." "."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$mysqli->close();