theloftstore/public/userarea/import_list_data.php

22 lines
756 B
PHP

<?php
header('Content-Type: application/json; charset=utf-8');
include('include/headscript.php');
require_once(__DIR__ . '/class/db-functions.php');
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
$idclient = isset($_GET['idclient']) && is_numeric($_GET['idclient']) ? intval($_GET['idclient']) : null;
try {
if ($idclient) {
$stmt = $pdo->prepare("SELECT * FROM importdb WHERE idclient = :idclient ORDER BY id DESC");
$stmt->execute([':idclient' => $idclient]);
} else {
$stmt = $pdo->query("SELECT * FROM importdb ORDER BY id DESC");
}
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
}