HEX
Server: LiteSpeed
System: Linux premium313.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User: wekawqug (1662)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/wekawqug/ndondocup.sisihub.co.tz/search.php
<?php
$q = $_GET['q'] ?? '';
if (!empty($q)) {
    // SQL query to fetch results
    $sql = "SELECT p.*, c.* FROM post_list p 
            JOIN category_list c ON p.category_id = c.id        
            WHERE (p.title LIKE '%$q%' OR p.content LIKE '%$q%' 
            OR c.category LIKE '%$q%' OR c.description LIKE '%$q%' 
            OR p.date_published LIKE '%$q%') AND p.status = 1";

    // Execute the query and fetch the results
    // Assuming $conn is your database connection
    $result = $conn->query($sql);

    // Generate HTML output for the results
    echo '<section id="search-result" class="search-result">';
    echo '<div class="container"><div class="row"><div class="col-md-9">';
    echo '<h3 class="category-title">Search Results</h3>';

    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            echo '<div class="d-md-flex post-entry-2 small-img">';
            echo '<a href="single-post.html" class="me-4 thumbnail">';
            echo '<img src="assets/img/person-1.jpg" alt="" class="img-fluid">';
            echo '</a><div>';
            echo '<div class="post-meta"><span class="date">' . $row['category'] . '</span>';
            echo '<span class="mx-1">&bullet;</span>';
            echo '<span>' . date('M jS \'y', strtotime($row['date_published'])) . '</span></div>';
            echo '<h3><a href="single-post.html">' . $row['title'] . '</a></h3>';
            echo '<p>' . substr($row['content'], 0, 150) . '...</p>';
            echo '</div></div></div>';
        }
    } else {
        echo '<p>No results found.</p>';
    }

    echo '</div></div></div></section>';
}