Example #1
0
File: Posts.php Project: VSG24/ccms
 function getSearchResultLoop($s, $max_pp = null)
 {
     if (!isset($this->p)) {
         $s = $this->conn->real_escape_string(urldecode($s));
         $loop_first_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized'";
         $this->res = $this->conn->query($loop_first_search_query);
         dbQueryCheck($this->res, $this->conn);
         $this->search_res_count = $this->res->num_rows;
         // set search result count, should be accessed only after function call
         $this->p = 'set';
     }
     if (!isset($loop_search_query)) {
         $s = $this->conn->real_escape_string(urldecode($s));
         $pagination = new Pagination($max_pp, $this->search_res_count);
         $loop_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized' ";
         $loop_search_query .= "LIMIT {$pagination->per_page} ";
         $loop_search_query .= "OFFSET {$pagination->offset()}";
     }
     if (!isset($this->j)) {
         $this->res = $this->conn->query($loop_search_query);
         dbQueryCheck($this->res, $this->conn);
         $this->j = 'set';
     }
     $this->total_pages = $pagination->totalPages();
     $this->hasPreviousPage = $pagination->hasPreviousPage();
     $this->hasNextPage = $pagination->hasNextPage();
     $this->previousPage = $pagination->previousPage();
     $this->nextPage = $pagination->nextPage();
     return $this->res->fetch_assoc();
 }
Example #2
0
            </a>
            <p><?php 
    echo $photo->caption;
    ?>
</p>
        </div>
    <?php 
}
?>
        
        <div id="pagination" style="clear: both;">
        <?php 
if ($pagination->totalPages() > 1) {
    if ($pagination->hasPreviousPage()) {
        echo " <a href=\"index.php?page=";
        echo $pagination->previousPage();
        echo "\">&laquo; Previous</a> ";
    }
    for ($i = 1; $i <= $pagination->totalPages(); $i++) {
        if ($i == $page) {
            echo " <span class=\"selected\">{$i}</span> ";
        } else {
            echo " <a href=\"index.php?page={$i}\">{$i}</a> ";
        }
    }
    if ($pagination->hasNextPage()) {
        echo " <a href=\"index.php?page=";
        echo $pagination->nextPage();
        echo "\">Next &raquo;</a> ";
    }
}