<?php
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	require('includes/application_top.php');
// Include the display function
function displaySeatPlan() {
    // Query to fetch all seat plan data ordered by products_row
    $query = "SELECT * FROM seat_plan ORDER BY products_id";
    $result = tep_db_query($query);

    if (!$result) {
        die('Error fetching data'); // Error handling without mysqli_error
    }

    echo '<h2>Seat Plan Table Data</h2>';
	echo '<button onclick="window.history.back();">Back</button>';
    echo '<table border="1" cellpadding="10" cellspacing="0" style="width: 100%; border-collapse: collapse;">';
    echo '<thead>';
    echo '<tr>';
    echo '<th>ID</th><th>Products Quantity</th><th>Products Name</th><th>Products Number</th><th>Color Code</th><th>Products Status</th><th>Products X</th><th>Products Y</th><th>Products W</th><th>Products H</th><th>Products R</th><th>Products SX</th><th>Products SY</th><th>Product Type</th>';
    echo '</tr>';
    echo '</thead>';
    echo '<tbody>';
    
    // Loop through the result set and display each row
    while ($row = tep_db_fetch_array($result)) {
        echo '<tr>';
        echo '<td>' . htmlspecialchars($row['products_id']) . '</td>';
        echo '<td>' . htmlspecialchars($row['products_quantity']) . '</td>';
        echo '<td>' . htmlspecialchars($row['products_name']) . '</td>';
        echo '<td>' . htmlspecialchars($row['products_number']) . '</td>';
        echo '<td>' . htmlspecialchars($row['color_code']) . '</td>';
        echo '<td>' . htmlspecialchars($row['products_status']) . '</td>';
        echo '<td>' . htmlspecialchars($row['products_x']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_y']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_w']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_h']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_r']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_sx']) . '</td>';
		echo '<td>' . htmlspecialchars($row['products_sy']) . '</td>';
		echo '<td>' . htmlspecialchars($row['product_type']) . '</td>';
        echo '</tr>';
    }

    echo '</tbody>';
    echo '</table>';
}

// Display the seat plan table
displaySeatPlan();

?>
