connect_error) { die("DB connection failed: " . $conn->connect_error); } $conn->set_charset('utf8mb4'); // Helper: safe escape function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } // --------------------------- // Load categories (id, name, slug) // If your categories table has `status`, we filter active; if not, we ignore it. // --------------------------- $categories = []; // Try with status filter first $sqlCats = " SELECT id, name, slug FROM rainyondo_categories WHERE COALESCE(NULLIF(TRIM(LOWER(status)), ''), 'active') = 'active' ORDER BY sort_order, name "; $res = $conn->query($sqlCats); // If the column `status` doesn't exist, retry without the filter if ($res === false) { $sqlCats = " SELECT id, name, slug FROM rainyondo_categories ORDER BY sort_order, name "; $res = $conn->query($sqlCats); } if ($res) { while ($row = $res->fetch_assoc()) { $categories[] = $row; } $res->free(); } // --------------------------- // Load books + category info // Treat NULL/blank status as 'active' so blanks don't hide everything. // --------------------------- $books_by_category = []; $sqlBooks = " SELECT b.*, c.name AS category_name, c.slug AS category_slug FROM rainyondo_books b LEFT JOIN rainyondo_categories c ON b.category_id = c.id WHERE COALESCE(NULLIF(TRIM(LOWER(b.status)), ''), 'active') = 'active' ORDER BY c.sort_order, b.sort_order, b.title "; if ($res = $conn->query($sqlBooks)) { while ($row = $res->fetch_assoc()) { $catSlug = $row['category_slug'] ?? ''; $catSlug = $catSlug !== '' ? $catSlug : 'other'; if (!isset($books_by_category[$catSlug])) { $books_by_category[$catSlug] = [ 'category_name' => $row['category_name'] ?? 'Other', 'books' => [] ]; } $books_by_category[$catSlug]['books'][] = $row; } $res->free(); } $conn->close(); ?> Rai Nyondo - Books Collection

Transform Your Life With Rai Nyondo's Books

Discover powerful insights on health, faith, finance, and personal growth

Special Limited Time Offers

Get up to 40% off on selected books. Expand your knowledge without expanding your budget!

View Offers

📌 Note: All eBooks are delivered automatically via email after payment confirmation. Please make sure your email address is correct at checkout.

$catData): ?>

Your Cart

Your cart is empty