D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
ashwika.encodersunlimited.com
/
Filename :
blogs.php
back
Copy
<?php require("style.php") ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Blogs</title> <style> /* Basic styling for blog display */ .blog-container { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; } .blog-item { border: 1px solid #ddd; border-radius: 5px; overflow: hidden; width: 300px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .blog-item img { width: 100%; height: 200px; object-fit: cover; } .blog-content { padding: 15px; } .blog-title { font-size: 1.25rem; margin: 0; } .blog-description { margin: 10px 0; font-size: 1rem; color: #666; } .read-more { text-align: right; } .read-more a { color: #007BFF; text-decoration: none; } </style> </head> <body> <?php require("header.php") ?> <div class="section-title text-center mt-5"> <h2 class="title">Latest Blogs</h2> <p class="sub-title">There are latest blog posts</p> </div> <div class="blog-container"> <?php // Include the database connection require('config.php'); // Fetch all blogs from the database $query = "SELECT id, title, description, image FROM blog"; $result = $conn->query($query); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { ?> <div class="blog-item"> <img src="ashadminwika/uploads/<?php echo htmlspecialchars($row['image']); ?>" alt="<?php echo htmlspecialchars($row['title']); ?>"> <div class="blog-content"> <h2 class="blog-title"><?php echo htmlspecialchars($row['title']); ?></h2> <p class="blog-description"><?php echo substr(htmlspecialchars($row['description']), 0, 100) . '...'; ?></p> <div class="read-more"> <a href="blog-details-image.php?id=<?php echo $row['id']; ?>">Read More</a> </div> </div> </div> <?php } } else { echo "<p>No blogs found.</p>"; } // Close the database connection $conn->close(); ?> </div> <?php require("footer.php") ?> </body> </html>