File "blog.php"

Full Path: /home/alphpwcp/previewstream.online/commentsos/commentsos/admin/blog.php
File size: 4 KB
MIME-type: text/x-php
Charset: utf-8

<?php
header('Content-Type: text/html; charset=UTF-8');
session_start();
include 'db.php';

// Fetch all blogs
$blogs = $pdo->query("SELECT * FROM blogs ORDER BY created_at DESC")->fetchAll();

// Fetch latest blogs for sidebar
$latestBlogs = $pdo->query("
  SELECT id, title 
  FROM blogs
  ORDER BY created_at DESC 
  LIMIT 5
")->fetchAll();

// Latest reviews
$latestReviews = $pdo->query("
  SELECT r.comment, r.rating, u.username, c.name AS company_name
  FROM reviews r
  JOIN users u ON r.user_id = u.id
  JOIN companies c ON r.company_id = c.id
  ORDER BY r.id DESC
  LIMIT 5
")->fetchAll();

// Top rated companies
$topCompanies = $pdo->query("
  SELECT c.id, c.name, c.image, ROUND(AVG(r.rating),1) AS avg_rating
  FROM companies c
  JOIN reviews r ON c.id = r.company_id
  GROUP BY c.id
  HAVING COUNT(r.id) >= 1
  ORDER BY avg_rating DESC
  LIMIT 5
")->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>News | Insights on Crypto, Forex, Mining & Digital Assets</title>
<meta name="description" content="Stay updated with expert articles, guides, and news from the crypto, forex, and digital asset space. Review Stream brings you insights to stay informed." />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

<!-- Sans-serif fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet">


<!-- Favicon -->
<link rel="icon" href="/favicon.png" type="image/png" />


<style>
body { margin:0; font-family:Arial,sans-serif; background:#f9f9f9; padding-bottom: 140px}
.container { max-width:1200px; margin:20px auto; padding:0 10px; }
.content-layout { display: flex; gap: 20px; flex-wrap: wrap; }
.main-content { 
  flex: 3; 
  min-width: 250px; 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
  gap: 15px; 
}
.sidebar { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 20px; }
.sidebar-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.07);
  transition: box-shadow 0.3s ease;
}
.sidebar-card:hover { box-shadow: 0 6px 14px rgba(0,0,0,0.12); }
.review-box {
  background: white;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
}
.hero {
  background: linear-gradient(90deg, #007BFF, #00b67a);
  color: white;
  text-align: center;
  padding: 40px 20px;
  border-radius: 12px;
  margin-bottom: 30px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}
.hero h2 { margin: 0; font-size: 28px; }
.star-box { display: inline-block; width: 20px; height: 20px; margin-right: 2px; text-align: center; line-height: 20px; border-radius: 3px; }
.star-box.filled { background: #00b67a; color: white; }
.star-box.empty { background: #d3d3d3; color: white; }
/* Blog cards grid style */
.blog-card { 
  background: white; 
  border-radius: 12px; 
  box-shadow: 0 4px 10px rgba(0,0,0,0.07); 
  overflow: hidden; 
  transition: transform 0.2s; 
  display: flex; 
  flex-direction: column;
}
.blog-card:hover { transform: translateY(-3px); }
.blog-card img { width: 100%; height: 150px; object-fit:cover; }
.blog-card-content { padding: 10px; }
.blog-card h4 { margin:0; font-size:16px; }
.blog-card p { font-size: 14px; color:#555; margin-top:5px; }

 .fixed-footer {
      position: fixed;
      left: 0;
      bottom: 0;
      width: 100%;
      background: #222;
      text-align: center;