Can anyone help me debug my webshop code

Hi

I’ve been practicing my PHP:).
I’m trying to build an example webshop.
Now I need some help, there are some things I can’t chew trough,
I translated most of the code to english, except PHP MySQLi functions.
I explain the code and what it needs to do in PHP comments


$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die('Error connecting to MySQL server.');
$product = array();
$rowcount = 0;
$_SESSION['order'] = array();
$_SESSION['order'][0] = array('Keyboard', 3, 'kg', 10);
// Example of order

// This function seems to be working just fine, so I think there is no need to check this.
function product_display(){
global $product, $rowcount, $dbc;
// Get the data from MySQL database and generate the product table
$query = "SELECT kaup, hind, yhik FROM kaubad";
$data = mysqli_query($dbc, $query) or die('Data not inserted DB_HOST');
	while ($row = mysqli_fetch_array($data)){
	array_push($product, array($row['kaup'], $row['hind'], $row['yhik']));
	// generate unique submit "buttons" by concatenating an index $rowcount to each name of submit
	echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
		  <table>
		  <tr> <th>Product:</th> <td>'.$product[$rowcount][0].'</td> </tr>
		  <tr> <th>Price:</th> <td>'.$product[$rowcount][1].'&nbsp;&nbsp;EUR</td> </tr>
		  <tr> <th>Quantity:</th> <td><input type="text" name="quantity" /></td> <td>'.$product[$rowcount][2].'</td> </tr>
		  <tr> <td><input type="submit" name="submit'.$rowcount.'" value="Add to cart"></td></tr> 
		  </table>
		  </form>';
	$rowcount++; 
	}
mysqli_close($dbc); 
}

//This form should be displayed when, an product is added to the Session variable order
function form_display() {
$order_length = sizeof($_SESSION['order']);
echo'<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
	 <table>
	 <tr> <th>Please fill this order form</th></tr>
	 <tr> <th>First name:</th> <td><input type="text" name="firstname" /></td> </tr>
	 <tr> <th>Last name:</th> <td><input type="text" name="lastname" /></td> </tr>
	 <tr> <th>Email:</th> <td><input type="text" name="email" /></td> </tr>
	 <tr><th>CART</th></tr>
	 <tr> <th>Product:</th> <th>Quantity</th> <th>Sum</th> </tr>';
// Loop trough the order array and display the products, with remove links.
for ($i = 0; $i < $order_length; $i++) {
echo'<tr> <td>'.$_SESSION['order'][$i][0].'</td> <td>'.$_SESSION['order'][$i][1].'</td> <td>'.($_SESSION['order'][$i][1]*$_SESSION['order'][$i][3]).'</td> 
	 <td><a href="veebipood.php?remove_product='.$i.'">Remove</a></td> </tr>'; 
}
echo'<tr> <td><input type="submit" name="order" value="Send order"></td></tr>
	 </table>
	 </form>';
}

// Call both functions, calling the form_display isn't what it needs to be. I want it to be called when there are items in Session variable order,
// I guess I could use IF statement something like not empty, but there's another problem, the list of items should be dynamic.
product_display();
form_display();

// This is the submit listener, if any of the forms are submitted this should start to work, I have a quess there is something wrong with this
for ($i = 0; $i <= $rowcount; $i++) {
	// If this submit is set, then push the data into Session variable order
	if (isset($_POST['submit'.$i.'']) && is_numeric($_POST['kogus'])) {
	$quantity = trim($_POST['quantity']);
	array_push($_SESSION['order'], array($product[$i][0], $product[$i][1], $product[$i][2], $quantity));
	} 
}
// Remove product from order when URL is Integer, from position $key and set the header back to the first page
if(!($_GET['remove_product'])){
$key = $_GET['remove_product'];
unset($_SESSION['order'][$key]);
header('location: veebipood.php');
}

Thanks, If anyone has some free time and wants to help, please do.