Learn by Directing AI
All materials

index.php

phpindex.php
<?php
require_once 'includes/db.php';
require_once 'includes/config.php';

$products = query_db("SELECT * FROM products ORDER BY id");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?php echo $site_name; ?> - <?php echo $site_tagline; ?></title>
    <style>
        body { font-family: Georgia, serif; margin: 0; padding: 0; background: #faf8f5; color: #333; }
        header { background: #8b6914; color: white; padding: 20px; text-align: center; }
        header h1 { margin: 0; font-size: 2em; }
        header p { margin: 5px 0 0; opacity: 0.9; }
        nav { background: #6b5010; padding: 10px; text-align: center; }
        nav a { color: white; text-decoration: none; margin: 0 15px; }
        .search-bar { padding: 15px; text-align: center; background: #f0ead6; }
        .search-bar input { padding: 8px 15px; width: 300px; border: 1px solid #ccc; }
        .search-bar button { padding: 8px 15px; background: #8b6914; color: white; border: none; cursor: pointer; }
        .products { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 20px; max-width: 1000px; margin: 0 auto; }
        .product { background: white; border: 1px solid #ddd; padding: 15px; text-align: center; }
        .product h3 { color: #8b6914; }
        .product .price { font-size: 1.2em; color: #333; font-weight: bold; }
        footer { background: #333; color: white; padding: 20px; text-align: center; margin-top: 40px; }
    </style>
</head>
<body>
    <header>
        <h1><?php echo $site_name; ?></h1>
        <p><?php echo $site_tagline; ?></p>
    </header>
    <nav>
        <a href="index.php">Shop</a>
        <a href="admin/">Admin</a>
        <a href="search.php">Search</a>
    </nav>
    <div class="search-bar">
        <form action="search.php" method="GET">
            <input type="text" name="q" placeholder="Search amber jewelry...">
            <button type="submit">Search</button>
        </form>
    </div>
    <div class="products">
        <?php while ($product = $products->fetch_assoc()): ?>
        <div class="product">
            <h3><?php echo $product['name']; ?></h3>
            <p><?php echo $product['description']; ?></p>
            <p class="price">&euro;<?php echo number_format($product['price'], 2); ?></p>
            <a href="product.php?id=<?php echo $product['id']; ?>">View Details</a>
        </div>
        <?php endwhile; ?>
    </div>
    <footer>
        <p>&copy; Gintaro Kelias - Klaipeda, Lithuania</p>
    </footer>
</body>
</html>