This commit is contained in:
Flatlogic Bot 2025-12-11 20:06:52 +00:00
parent 2c6fd9a176
commit b450e7e6df
4 changed files with 18 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

14
debug_schema.php Normal file
View File

@ -0,0 +1,14 @@
<?php
require_once 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->query("DESCRIBE items");
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($columns);
echo "</pre>";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>

View File

@ -8,7 +8,7 @@ if (isset($_GET['download_csv'])) {
$user_id = $_SESSION['user_id']; $user_id = $_SESSION['user_id'];
$pdo = db(); $pdo = db();
$query = "SELECT name, description, price, location, status, creation_date FROM items WHERE owner_id = ?"; $query = "SELECT name, description, price, location, status, creation_date FROM items WHERE vendor_id = ?";
$query_params = [$user_id]; $query_params = [$user_id];
if (isset($_GET['search']) && !empty($_GET['search'])) { if (isset($_GET['search']) && !empty($_GET['search'])) {
@ -92,7 +92,7 @@ $pdo = db(); // Get the PDO connection
$items = []; // Initialize an empty array to hold items $items = []; // Initialize an empty array to hold items
// Fetch items listed by the current vendor // Fetch items listed by the current vendor
$total_items_query = "SELECT COUNT(*) FROM items WHERE owner_id = ?"; $total_items_query = "SELECT COUNT(*) FROM items WHERE vendor_id = ?";
$total_items_params = [$user_id]; $total_items_params = [$user_id];
if (isset($_GET['search']) && !empty($_GET['search'])) { if (isset($_GET['search']) && !empty($_GET['search'])) {
@ -116,10 +116,10 @@ $items = []; // Initialize an empty array to hold items
$current_page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $current_page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$current_page = max(1, min($current_page, $total_pages == 0 ? 1 : $total_pages)); // Ensure current page is within valid range $current_page = max(1, min($current_page, $total_pages == 0 ? 1 : $total_pages)); // Ensure current page is within valid range
$offset = ($current_page - 1) * ITEMS_PER_PAGE; $offset = ($current_page - 1) * $items_per_page;
// Fetch items listed by the current vendor // Fetch items listed by the current vendor
$query = "SELECT * FROM items WHERE owner_id = ?"; $query = "SELECT * FROM items WHERE vendor_id = ?";
$query_params = [$user_id]; $query_params = [$user_id];
if (isset($_GET['search']) && !empty($_GET['search'])) { if (isset($_GET['search']) && !empty($_GET['search'])) {