I building an inventory management solutions in php for my father's shop. This is the code what lists the inventory in table from MySQL database.
<?php
$sql = "SELECT * FROM inventory";
$res = mysqli_query($conn, $sql) or die ('Wrong statement!');
echo '<table border=1>';
echo '<tr>';
echo '<th>ID</th>';
echo '<th>Type</th>';
echo '<th>Name</th>';
echo '<th>Wholesaleprice</th>';
echo '<th>Price</th>';
echo '<th>Supplier</th>';
echo '<th>Place</th>';
echo '<th>Place2</th>';
echo '<th>Count</th>';
echo '<th>Barcode</th>';
echo '<th>Last Change</th>';
echo '<th>Details</th>
echo '</tr>';
while ( ($current_row = mysqli_fetch_assoc($res))!= null) {
echo '<tr>';
echo '<td>' . $current_row["ID"] . '</td>';
echo '<td>' . $current_row["type"] . '</td>';
echo '<td>' . $current_row["name"] . '</td>';
echo '<td>' . $current_row["wholeprice"] . '</td>';
echo '<td>' . $current_row["price"] . '</td>';
echo '<td>' . $current_row["wholesaler"] . '</td>';
echo '<td>' . $current_row["whereis"] . '</td>';
echo '<td>' . $current_row["whereis2"] . '</td>';
echo '<td>' . $current_row["count"] . ' ' . $current_row["dimension"] . '</td>';
echo '<td>' . $current_row["barcode"] . '</td>';
echo '<td>' . $current_row["lastchange"] . '</td>';
echo '<td> HERE GOES THE BUTTON </td>';
echo '</tr>';
}
echo '</table>';
mysqli_free_result($res);?>
How I can put a button (form or button class), what navigates to the "productdetails.php" and pass the current row's barcode as a variable, too?
I tried:
<form action="productdetails.php" method="get">
<button type="submit" class="button" value="' . $current_row["barcode"] . '">Product Details</button>
</form>