D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
www
/
Filename :
blog.php
back
Copy
<?php include 'database.php'; // Include your database connection file // Fetch blogs from the database $query = "SELECT id, title, content, image, short_desc, created_at FROM blogs ORDER BY created_at DESC"; $result = mysqli_query($conn, $query); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Our Blogs</title> <script> (function(w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-59KBRCW8'); </script> <!-- End Google Tag Manager --> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="IE=7"> <!-- ========== Page Title ========== --> <title>Encoders Unlimited - IT Solution and Consulting Service</title> <!-- ========== Start Fonts Style ========== --> <link rel="preconnect" href="https://fonts.googleapis.com/"> <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin> <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100;0,9..40,200;0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,100;1,9..40,200;1,9..40,300;1,9..40,400;1,9..40,500;1,9..40,600&family=Syne:wght@400;500;600&family=Yantramanav:wght@100;300;400;500;700;900&display=swap" rel="stylesheet"> <!-- ========== Start Stylesheet ========== --> <link rel="stylesheet" href="../../../cdn.jsdelivr.net/gh/iconoir-icons/iconoir%40main/css/iconoir.css"> <link rel="stylesheet" href="../../../maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css"> <link rel="stylesheet" href="assets/css/bootstrap.min.css"> <link rel="stylesheet" href="assets/css/swiper-bundle.min.css" /> <link rel="stylesheet" href="assets/css/style.css"> <link rel="stylesheet" href="assets/css/responsive.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"> <!-- ========== End Stylesheet ========== --> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-5KDPBG8Z3Z"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'G-5KDPBG8Z3Z'); </script> </head> <body> <style> @import url("https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i"); @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); html { color: #242A31; background: #fff; font-family: "Lato", sans-serif; line-height: 1.4; box-sizing: border-box; -webkit-text-size-adjust: 100%; } *, *:before, *:after { box-sizing: inherit; } body { margin: 0; font-size: 14px; } a { color: #26A3FF; -webkit-text-decoration-skip: ink; text-decoration-skip: ink; } .center-xy { top: 50%; left: 50%; transform: translate(-50%, -50%); position: absolute; } .no-scroll { overflow: hidden; } .img-responsive { width: 100%; display: block; } .rounded-circle { border-radius: 100%; } .rounded-sm { border-radius: 6px; } .rounded-md { border-radius: 8px; } .rounded-lg { border-radius: 12px; } .spacer-y { margin-top: 30px; margin-bottom: 30px; } .skew { transform: skew(23deg); } .skew .unskew { transform: skew(-23deg); } .main-container { margin-top: 50px; } .post { margin: 0 auto; padding: 30px 0; border-bottom: 1px solid #ececec; } .post:last-of-type { padding-bottom: 0; border-bottom: none; } .post .post-meta--user { margin-bottom: 10px; display: flex; align-items: center; } .post .post-meta--user img, .post .post-meta--user p { vertical-align: middle; display: inline; float: left; } .post .post-meta--user img { width: 40px; } .post .post-meta--user p { color: #91A8BD; line-height: 1.3; margin: 0 0 0 10px; } .post .post-meta--user a { display: inline-block; } .post .post-meta--post { color: #fff; width: 100%; position: absolute; bottom: 0; } .post .post-meta--post .post-meta--item { padding: 12px 15px; } .post .post-meta--post svg { display: inline-block; vertical-align: middle; } .post .post-meta--post .post-comments { float: left; } .post .post-meta--post .post-comments .post-comments--counter { font-size: 12px; font-family: monospace; } .post .post-meta--post .post-share { float: right; } .post .post-heading { font-size: 18px; line-height: 1.2; margin: 15px 0; font-family: "Poppins", serif; } .post .post-heading a { color: inherit; text-decoration: none; font-family: "Poppins", serif; } .post .post-body { font-size: 12px; margin: 0; font-family: "Poppins", serif; } .sidebar-container { margin: 30px 0; } .sidebar-container a { color: inherit; text-decoration: none; } .sidebar-container .sidebar-heading-container { text-align: center; display: 0 block; } .sidebar-container .sidebar-heading { font-size: 24px; text-align: center; margin: 0; position: relative; display: inline-block; } .sidebar-container .sidebar-heading:before { content: ""; background: #FFE822; width: 104%; height: 11px; margin-left: -2%; bottom: 5px; position: absolute; z-index: -1; opacity: 0.4; } .sidebar-container .post-sidebar { display: block; align-items: end; margin: 50px 70px; } .sidebar-container .post-sidebar img { margin-right: 10px; } .sidebar-container .post-sidebar p { margin: 0; } .sidebar-container .post-sidebar .post-heading { font-weight: 600; font-family: "Poppins", serif; } .sidebar-container .post-sidebar .post-date { color: #91A8BD; padding-bottom: .5rem; border-bottom: 1px solid #91A8BD; } .post-related-container { padding: 30px 0; } .post-related-container .post-related:not(:last-of-type) { margin-bottom: 30px; } .post-related-container .post-heading { font-size: 18px; margin: 10px 0 0; font-family: "Poppins", serif; } .img-container { position: relative; overflow: hidden; margin: auto; } .img-container .img-container-content { background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2)); width: 100%; height: 100%; top: 0; right: 0; position: absolute; } .blog-img { height: 400px; margin: auto; } .img-container .btn-category { background: #FFE822; font-size: 14px; font-weight: 600; margin-right: -10px; padding-right: 3px; right: 0; position: absolute; } .btn { text-decoration: none; text-align: center; display: inline-block; } .btn span { padding: 8px 20px; display: block; } .footer { padding: 15px 0; border-top: 1px solid #efefef; } .footer p { margin: 0; } .footer p:first-of-type { font-size: 18px; font-weight: 600; } .footer p:last-of-type { color: #ffffff; } .cb-logo--elem { fill: #242A31; } .svg-icon { width: 1.5em; height: 1.5em; } .svg-icon path, .svg-icon polygon, .svg-icon rect { fill: currentColor; } .svg-icon circle { stroke: currentColor; stroke-width: 1; } .nav { width: 100%; height: 100%; z-index: 13000; } .nav-bar { color: #000; background: #fff; text-align: right; line-height: 1; vertical-align: middle; width: 100%; height: 50px; padding: 0 5px; border-bottom: 1px solid #e9e9e9; top: 0; position: fixed; display: table; z-index: 12000; } .nav-brand { top: 0; left: 0; right: 0; bottom: 0; position: absolute; width: 100px; height: 22px; margin: auto; display: block; } .nav-toggle { font-size: 20px; vertical-align: middle; margin-top: 5px; display: table-cell; cursor: pointer; float: right; } .navicon { padding: 9px 10px; cursor: pointer; position: relative; } .navicon .navicon-line { background: #242A31; width: 22px; height: 2px; margin: 4px 0; border-radius: 1px; display: block; transition: all 0.2s ease; } .nav-list { background: #f9f9f9; width: 100%; margin-top: 50px; top: 0; position: fixed; overflow-y: scroll; -webkit-overflow-scrolling: touch; -ms-overflow-style: none; z-index: 11000; } .nav-list ul { margin: 0; padding: 0; list-style-type: none; } .nav-list li { display: block; vertical-align: middle; } .nav-list li:first-of-type, .nav-list li:last-of-type { margin-top: 10px; } .nav-list li:hover { background: #f1f1f1; } .nav-list a { color: inherit; font-size: 14px; font-weight: 600; text-decoration: none; text-align: center; padding: 12px 20px; display: block; } .nav-backdrop { background: rgba(0, 0, 0, 0.7); width: 200%; height: 200%; position: fixed; z-index: 10000; } .nav-search--form { font-size: 0; border-top: 1px solid #e9e9e9; background: #efefef; } .nav-search--search { font-size: 16px; background: transparent; vertical-align: middle; width: 100%; margin: 0; padding: 14px 46px 14px 14px; border: none; -webkit-appearance: none; display: inline-block; } .nav-search--btn { color: #fff; background: #FF268E url(http://www.clker.com/cliparts/v/C/2/9/I/6/search-icon-white-hi.png); background-size: 14px; background-repeat: no-repeat; background-position: center center; font-size: 14px; vertical-align: middle; width: 30px; height: 30px; right: 0; margin: 8px; position: absolute; border: none; border-radius: 100%; -webkit-appearance: none; display: inline-block; } .post-container { display: flex; flex-wrap: wrap; gap: 20px; /* Adds spacing between posts */ } .post { flex: 1 1 calc(50% - 20px); /* Ensures two columns with some spacing */ box-sizing: border-box; padding: 15px; border: 1px solid #ddd; border-radius: 8px; background-color: #f9f9f9; position: relative; } .post:not(:last-child) { border-bottom: 1px solid #ccc; /* Line after each post */ padding-bottom: 15px; margin-bottom: 15px; } .img-container img { width: 100%; height: auto; border-radius: 8px; } .sidebar-container { position: sticky; top: 20px; /* The distance from the top when it becomes fixed */ padding: 15px; border: 1px solid #ddd; border-radius: 8px; background-color: #f9f9f9; } @media (max-width: 768px) { .post { flex: 1 1 100%; /* Changes to a single column on smaller screens */ } .sidebar-container { position: relative; /* Removes sticky behavior on smaller screens */ } } @media screen and (max-width: 576px) { .nav .container { padding: 0; } } @media screen and (min-width: 576px) { .nav-toggle { display: none; } .nav-brand { right: auto; margin-left: 15px; } .nav-list { background-color: transparent; width: auto; margin-top: 0; right: 0; z-index: 12000; } .nav-list li { display: inline-block; } .nav-list li:first-of-type, .nav-list li:last-of-type { margin-top: 0; } .nav-list a { padding: 15px 10px; } .nav-backdrop { display: none; } .nav-search--form { display: none; } .footer { padding: 30px 0; } } @media screen and (min-width: 768px) { .post-related-container .post-related { margin-bottom: 0; } .img-container{ margin: auto; } } </style> <?php // Include your database connection include 'config.php'; // Fetch blogs from the database, include `id` in the query $query = "SELECT id, title, content, image, short_desc, created_at FROM blogs ORDER BY created_at DESC"; $result = mysqli_query($conn, $query); // Function to limit the content to 150 words function getExcerpt($content, $wordLimit = 150) { // Remove HTML tags and decode entities $content = strip_tags($content); // Split the content into an array of words $words = explode(' ', $content); // Check if the word count exceeds the limit if (count($words) > $wordLimit) { // Trim the content to the word limit and add ellipsis $content = implode(' ', array_slice($words, 0, $wordLimit)) . '...'; } else { // If word count is less than the limit, return content as is $content = implode(' ', $words); } return $content; } ?> <div class="main-container container"> <?php include 'header.php'; ?> <div class="row"> <div class="col-12 col-md-8"> <div class="post-container"> <?php while ($row = mysqli_fetch_assoc($result)): // Assign the title and image variables $id = $row['id']; $title = $row['title']; $image = $row['image']; $short_desc = $row['short_desc'] ?> <article class="post"> <!-- Meta --> <div class="post-byline post-meta--user"> <p>Posted on <?php echo date('F j, Y', strtotime($row['created_at'])); ?></p> </div> <!-- Image --> <div class="img-container rounded-sm"> <img class="blog-img" src="encoadminders/<?php echo htmlspecialchars($image); ?>" alt="<?php echo htmlspecialchars($title); ?>" /> </div> <!-- Title --> <header> <h1 class="post-heading"> <a href="blog-details.php?id=<?php echo urlencode($id); ?>"><?php echo htmlspecialchars($title); ?></a> </h1> </header> <!-- Content --> <p class="post-body"> <?php echo ($row['short_desc']); ?> <a href="blog-details.php?id=<?php echo urlencode($id); ?>">Read More</a> </p> </article> <?php endwhile; ?> </div> </div> <div class="col-12 col-md-4"> <aside class="sidebar-container"> <div class="sidebar-heading-container"> <h1 class="sidebar-heading">Recent Blogs</h1> </div> <?php // Fetch recent blogs for sidebar $sidebarQuery = "SELECT title, image, created_at FROM blogs ORDER BY created_at DESC LIMIT 5"; $sidebarResult = mysqli_query($conn, $sidebarQuery); while ($sidebarRow = mysqli_fetch_assoc($sidebarResult)): ?> <div class="post-sidebar"> <header> <a href="blog-details.php?id=<?php echo urlencode($id); ?>"><p class="post-heading"><?php echo htmlspecialchars($sidebarRow['title']); ?></p></a> <p class="post-date"><?php echo date('F j, Y', strtotime($sidebarRow['created_at'])); ?></p> </header> </div> <?php endwhile; ?> </aside> </div> </div> </div> <footer> <?php require('footer.php') ?> </footer> <script> // nav toggle vars var tl = new TimelineMax(), setTL = new TimelineMax(), navIsOpen = false, $body = $('body'), $navToggle = $('.nav-toggle'), $navClose = $('.nav-close'), $navBar = $('.nav-bar'), $navList = $('.nav-list'), $navBackdrop = $('.nav-backdrop'), $navLogo = $('.nav-logo'), $cbLogoElem = $('.cb-logo--elem'), $navSearchBtn = $('.nav-search--btn'); // navicon vars var naviconTL, $navicon = $navToggle.find('.navicon'), $naviconLine = $navToggle.find('.navicon-line'), navLineDuration = 0.1, navLineRotationDelay = 0.3, navLineEase = Back.easeInOut.config(1.7); // colors var $cbBlue = '#26a3ff' // set positioning setTL.set($navList, { yPercent: -100 }); setTL.set($navList.find('li'), { autoAlpha: 0, y: -15 }); setTL.set($navBackdrop, { autoAlpha: 0 }); setTL.set($navSearchBtn, { scale: 0 }); // setTL.add(showNav, 0.5); // animate nav at start // event handlers $navToggle.on('click', function() { !navIsOpen ? showNav() : hideNav(); console.log('Nav toggle click'); }) $navClose.on('click', function() { hideNav(); console.log('Nav close click'); }) $navBackdrop.on('click', function() { if (navIsOpen) { hideNav(); console.log('Nav overlay click'); } }) $(window).resize(function() { handleResize(); }); // functions function showNav() { navIsOpen = true; console.log('Nav Open:', navIsOpen); tl.play(); tl.addLabel('nav-toggle') tl.to($navBackdrop, 0.3, { autoAlpha: 1, ease: Power1.easeInOut }, 'nav-toggle'); tl.to($cbLogoElem, 0.3, { fill: $cbBlue }, 'nav-toggle'); tl.to($navLogo, 0.3, { scale: 0.8, ease: Back.easeInOut.config(1.7) }, 'nav-toggle'); tl.to($naviconLine, 0.3, { background: $cbBlue }, 'nav-toggle+=0.2'); tl.to($navList, 0.3, { yPercent: 0, ease: Power4.easeOut }, 'nav-toggle+=0.2'); tl.staggerTo($navList.find('li'), 0.3, { autoAlpha: 1, y: 0, ease: Power1.easeInOut, onComplete: function() { tl.to($navSearchBtn, 0.3, { scale: 1, ease: Back.easeInOut.config(1.7) }, 'nav-toggle+=0.5'); } }, 0.03, 'nav-toggle+=0.2'); naviconClosedState(this); $body.addClass('no-scroll'); } function hideNav() { navIsOpen = false; console.log('Nav Open:', navIsOpen); tl.reverse().seek(0.3); // speed up reverse naviconOpenState(this); $body.removeClass('no-scroll'); } function handleResize() { windowWidth = $(window).width(); windowHeight = $(window).height(); console.log(windowWidth, windowHeight); // if (window.matchMedia("(min-width: 576px)").matches) { // showNav(); // } } // ===== NAVICON TOGGLE ===== // // toggle hamburger icon to close icon $navicon.each(function(index) { naviconTL = new TimelineMax(); $(this).on('click', function() { if (!$(this).hasClass('is-active')) { naviconClosedState(this, index); } else { naviconOpenState(this, index); } }); }); function naviconClosedState(_this, _index) { console.log('icon ' + _index + ': addClass'); $(_this).addClass('is-active'); naviconTL.play() // TIMELINE naviconTL.addLabel('navicon', 0); // move to center naviconTL.to($(_this).find('.navicon-line:nth-of-type(1)'), navLineDuration, { y: 6, ease: navLineEase }, 'navicon'); naviconTL.to($(_this).find('.navicon-line:nth-of-type(3)'), navLineDuration, { y: -6, ease: navLineEase }, 'navicon'); // hide naviconTL.to($(_this).find('.navicon-line:nth-of-type(2)'), navLineDuration, { autoAlpha: 0, scale: 0, ease: navLineEase }, 'navicon'); // rotate naviconTL.to($(_this).find('.navicon-line:nth-of-type(1)'), navLineDuration, { rotation: 45, ease: navLineEase }, 'navicon' + '+=' + navLineRotationDelay); naviconTL.to($(_this).find('.navicon-line:nth-of-type(3)'), navLineDuration, { rotation: -45, ease: navLineEase }, 'navicon' + '+=' + navLineRotationDelay); } function naviconOpenState(_this, _index) { console.log('icon ' + _index + ': removeClass'); $(_this).removeClass('is-active'); naviconTL.reverse(); } // EXAMPLE BLOG CONTENT var $post = $('.post'), $postSidebar = $('.post-sidebar'), $postRelated = $('.post-related'), totalPosts = 3, totalSidebarPosts = 5, totalRelatedPosts = 3; loopContent(loopLoaded); function loopLoaded() { console.log('loop loaded') } function loopContent(callback) { for (var i = 0; i < totalPosts - 1; i++) { $post.first().clone().appendTo('.post-container'); } for (var i = 0; i < totalSidebarPosts - 1; i++) { $postSidebar.first().clone().appendTo('.sidebar-container'); } for (var i = 0; i < totalRelatedPosts - 1; i++) { $postRelated.first().clone().appendTo('.post-related-container .row'); } if (typeof callback === 'function') { callback(); } } </script> <!-- jQuery Frameworks ============================================= --> <script src="assets/js/jquery-3.7.0.min.js"></script> <script src="assets/js/bootstrap.bundle.min.js"></script> <script src="assets/js/gsap.min.js"></script> <script src="assets/js/Draggable.min.js"></script> <script src="assets/js/swiper-bundle.min.js"></script> <script src="assets/js/client-marquee.js"></script> <script src="assets/js/theme-custom.js"></script> <script src="assets/js/form1.js"></script> <script src="assets/js/subscribe-form.js"></script> </body> </html>