set_charset("utf8"); // Get category name from the URL $categoryName = str_replace('-', ' ', urldecode(basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '.html'))); // Find the category ID based on the category name $categoryQuery = "SELECT ID FROM ncategories WHERE Name = '" . $conn->real_escape_string($categoryName) . "' AND MainCat = 0"; $categoryResult = $conn->query($categoryQuery); if (!$categoryResult || $categoryResult->num_rows == 0) { die("Invalid category."); } $categoryId = $categoryResult->fetch_assoc()['ID']; // Define items per page $itemsPerPage = 6; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $itemsPerPage; // Check if the requested category is "فيديو" for specific query adjustment if ($categoryName === "فيديو") { $blogsQuery = "SELECT * FROM news WHERE mobilevideo != '' AND mStatus=1 ORDER BY pdate DESC LIMIT $offset, $itemsPerPage"; } else { // Query for blogs with the given category ID $blogsQuery = "SELECT * FROM news WHERE mCat = $categoryId AND mStatus=1 ORDER BY pdate DESC LIMIT $offset, $itemsPerPage"; } $blogsResult = $conn->query($blogsQuery); if (!$blogsResult) { die("Error in blogs query: " . $conn->error); } // Query for total count (for pagination) if ($categoryName === "فيديو") { $countQuery = "SELECT COUNT(*) as total FROM news WHERE mobilevideo != '' AND mStatus=1"; } else { $countQuery = "SELECT COUNT(*) as total FROM news WHERE mCat = $categoryId AND mStatus=1"; } $countResult = $conn->query($countQuery); if (!$countResult) { die("Error in count query: " . $conn->error); } $totalBlogs = $countResult->fetch_assoc()['total']; $totalPages = ceil($totalBlogs / $itemsPerPage); ?> جمعية نيسان لصّحة الجهاز الهضمي، الكبد والّتغذية الصحية
num_rows > 0): ?> fetch_assoc()): ?>

لا توجد مقالات لعرضها.

1): ?>