mig
This commit is contained in:
46
.hta_slug/admin/test.php
Normal file
46
.hta_slug/admin/test.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Database connection failed: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Pagination variables
|
||||
$limit = 10; // Number of records per page
|
||||
$page = isset($_GET['page']) ? $_GET['page'] : 1; // Current page number
|
||||
$offset = ($page - 1) * $limit; // Offset for pagination
|
||||
|
||||
// Fetch products with pagination
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT * FROM cleads LIMIT :limit OFFSET :offset");
|
||||
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Count total number of products
|
||||
$totalStmt = $pdo->query("SELECT COUNT(*) FROM products");
|
||||
$totalProducts = $totalStmt->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
die("Error fetching products: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Display products
|
||||
echo "<h1>Product List</h1>";
|
||||
|
||||
echo "<ul>";
|
||||
foreach ($products as $product) {
|
||||
echo "<li>{$product['id']} - {$product['name']}</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
// Pagination links
|
||||
$totalPages = ceil($totalProducts / $limit);
|
||||
echo "<div>";
|
||||
echo "<h3>Pages:</h3>";
|
||||
for ($i = 1; $i <= $totalPages; $i++) {
|
||||
echo "<a href='?page=$i'>$i</a> ";
|
||||
}
|
||||
echo "</div>";
|
||||
?>
|
||||
Reference in New Issue
Block a user