MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/destinytrafficsolutions/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/destinytrafficsolutions/admin/index.php
<?php
// Enable error reporting for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();
include("inc/config.php");

// Query to fetch categories with the highest click count
$query = "
    SELECT 
        c.id AS category_id, 
        c.v_name, 
        MAX(c.photo) AS photo, 
        COALESCE(MAX(cr.click_count), 0) AS highest_clicks
    FROM categories c
    LEFT JOIN click_records cr ON cr.category_id = c.id
    GROUP BY c.id, c.v_name
    ORDER BY highest_clicks DESC  -- Sorting by highest clicks first
";

$query_run = mysqli_query($conn, $query);
?>

<!DOCTYPE html>
<html lang="en">
   <?php require "inc/head.php"; ?>
   <body>
      <!-- header-->
      <?php require "inc/header.php"; ?>

      <div class="wrapper">
         <?php require "inc/sidebar.php"; ?>
         <div id="content">
            <div class="row">
               <div class="col-sm-12">
                  <div class="row mb-xl-4 mb-0">

                    <!-- Loop Through Categories and Display -->
                    <?php
                    if (mysqli_num_rows($query_run) > 0) {
                        while ($row = mysqli_fetch_assoc($query_run)) { ?>
                            <div class="col-4 col-sm-6 col-xl-3 mb-4">
                      
                            <!-- <div class="col-12 col-sm-6 col-xl-3 mb-4"> -->
                                <div class="card redial-border-primary redial-shadow redial-bg-primary text-white">
                                    <div class="card-body text-center">
                                        <h4 class="v_name"><?php echo htmlspecialchars($row['v_name']); ?></h4>
                                        
                                        <!-- Show category image -->
                                        <img src="<?php echo !empty($row['photo']) ? "../admin/category/" . htmlspecialchars($row['photo']) : 'default-image.jpg'; ?>" 
                                             alt="Category Image" style="max-width: 70px; height: 37px;">
                                        
                                        <!-- Display Highest Click Count -->
                                        <h2 class="mb-1 redial-font-weight-400 text-white count">
                                            <?php echo $row['highest_clicks']; ?>
                                        </h2>
                                    </div>
                                </div>
                            </div>
                    <?php }
                    } else {
                        echo "<p>No categories found.</p>";
                    }
                    ?>

                  </div>
               </div>
            </div>
         </div>
      </div>

      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      <script src="dist/js/plugins.min.js"></script>
      <script src="dist/js/common.js"></script>
   </body>
</html>

MMCT - 2023