offset() public method

Returns the current offset This is used for the slice() method together with the limit to get the correct items from collections
public offset ( ) : integer
return integer
 static function find_paginated($page = 1, $fields = "*", $where_clause = "", $order = "ASC")
 {
     $total_count = static::count_all();
     $pagination = new Pagination($page, $total_count, ITEMS_PER_PAGE);
     $query = "SELECT {$fields} FROM `" . static::$table_name . "` ";
     $query .= $where_clause;
     $query .= "ORDER BY `" . ID . "` {$order} ";
     $query .= "LIMIT " . ITEMS_PER_PAGE . " ";
     $query .= "OFFSET " . $pagination->offset();
     return static::find_by_query($query);
 }
 /**
  * Return a subset of property objects to use 
  * in pagination of records
  * @param object $paginationObj A pagination object
  * @return array An array of property objects
  */
 public static function getSubsetOfProperties(Pagination $paginationObj)
 {
     $db = Database::getInstance();
     $mysqli = $db->getConnection();
     $sql = "SELECT * FROM property p ORDER BY name ASC ";
     $sql .= "LIMIT " . $mysqli->real_escape_string($paginationObj->per_page) . " ";
     $sql .= "OFFSET " . $paginationObj->offset();
     return static::findBySql($sql);
 }
        redirect_to($_SERVER['PHP_SELF']);
        die;
    }
}
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$per_page = JOBS_PER_SEARCH;
$total_count = Job::count_all();
$smarty->assign('total_count', $total_count);
$smarty->assign('page', $page);
$pagination = new Pagination($page, $per_page, $total_count);
$smarty->assign('previous_page', $pagination->previous_page());
$smarty->assign('has_previous_page', $pagination->has_previous_page());
$smarty->assign('total_pages', $pagination->total_pages());
$smarty->assign('has_next_page', $pagination->has_next_page());
$smarty->assign('next_page', $pagination->next_page());
$offset = $pagination->offset();
$sql = " SELECT * FROM " . TBL_JOB;
$sql .= " LIMIT {$per_page} ";
$sql .= " OFFSET {$offset} ";
$lists = Job::find_by_sql($sql);
$manage_lists = array();
if ($lists && is_array($lists)) {
    $i = 1;
    foreach ($lists as $list) {
        unset($employer);
        if (!empty($list->fk_employer_id) && $list->fk_employer_id != 0) {
            $employer = Employer::find_by_id($list->fk_employer_id);
        }
        $manage_lists[$i]['id'] = $list->id;
        $manage_lists[$i]['job_title'] = $list->job_title;
        $manage_lists[$i]['spotlight'] = $list->spotlight == "Y" ? "Spotlight Job" : "Standard Job";
Example #4
0
<?php

include "includes/header.php";
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$items_per_page = 2;
$items_total_count = Photo::count_all();
$pages = ceil($items_total_count / $items_per_page);
$paginate = new Pagination($page, $items_per_page, $items_total_count);
$query = "SELECT * FROM photos ";
$query .= " LIMIT {$items_per_page} ";
$query .= "OFFSET {$paginate->offset()}";
$photos = Photo::find_this_query($query);
?>


<div class="row">

    <!-- Blog Entries Column -->
    <div class="col-md-12">
        <div class="thumbnails row">
            <?php 
foreach ($photos as $photo) {
    ?>

                <div class="col-xs-6 col-md-3">
                    <a href="<?php 
    echo 'photo.php?id=' . $photo->id;
    ?>
" class="thumbnail">
                        <img class="gallery_photo img-responsive"
                             src="<?php 
Example #5
0
 /**
  * Add pagination
  *
  * @param int $limit the number of items per page
  * @param array $options and optional array with options for the pagination class
  * @return object a sliced set of data
  */
 public function paginate($limit, $options = array())
 {
     if (is_a($limit, 'Pagination')) {
         $this->pagination = $limit;
         return $this;
     }
     $pagination = new Pagination($this->count(), $limit, $options);
     $pages = $this->slice($pagination->offset(), $pagination->limit());
     $pages->pagination = $pagination;
     return $pages;
 }
Example #6
0
<?php

require_once '../includes/initialize.php';
?>

<?php 
include_layout_template("header.php");
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$record_no = 3;
$total_records = Photograph::count();
// $photo_object = new Photograph();
// $photos = $photo_object->find_all();
$pagination = new Pagination($page, $record_no, $total_records);
$sql_query = "SELECT * FROM photograph ";
$sql_query .= "LIMIT {$record_no} ";
$sql_query .= "OFFSET {$pagination->offset()} ";
$photos = Photograph::find_by_sql($sql_query);
?>
	<h2>Photos</h2>
	<?php 
echo output_message($session->set_get_message());
?>
		<?php 
foreach ($photos as $photo) {
    ?>
		   <div style="float:left;margin-left: 20px; display:inline;">
		   	<a href="photo.php?id=<?php 
    echo $photo->id;
    ?>
">
		   		<img src="<?php 
Example #7
0
print_r($ques_status);
echo "<br/>";*/
$ques_options = $_SESSION['temp_options'];
$pg = new Pagination($page, $per_page, $total_count);
$tt = new Test();
if (isset($_SESSION['first_time'])) {
    $tt->Review_Test();
} else {
    unset($_SESSION['first_time']);
}
$ques_set = $tt->GetAllQues();
?>
    <table width="933" border="0" cellspacing="0" cellpadding="0" class="revtab">
    <?php 
$check = $per_page * $page > $total_count ? $total_count : $per_page * $page;
for ($i = $pg->offset(); $i < $check; $i++) {
    $id = $ques_ids[$i];
    ?>
  <tr>
    <td width="53"><?php 
    echo $i + 1;
    ?>
</td>
    <td width="687" ><?php 
    echo $ques_set[$i];
    ?>
</td>
    <td><input type="button" class="button orange" onClick="call_test(<?php 
    echo $id;
    ?>
,'<?php 
Example #8
0
            $updated_session = [SessionOperator::SORT => $sort];
        } else {
            HelperOperator::redirectTo("../views/search_view.php");
            return;
        }
    }
}
$cats = getCatIdAndType($searchCategory);
// Set up pagination object
$total = QueryOperator::countFoundAuctions(buildQuery($searchString, $cats, null));
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$page = $page <= $total ? $page : 1;
$per_page = 15;
$pagination = new Pagination($page, $per_page, $total);
// Get paginated search results
$catsAndAuctions = QueryOperator::searchAuctions(buildQuery($searchString, $cats, $sort, $per_page, $pagination->offset()));
// Update search sessions
$updated_session = array_merge([SessionOperator::SEARCH_RESULT => $catsAndAuctions], $updated_session);
$updated_session = array_merge([SessionOperator::SEARCH_PAGINATION => $pagination], $updated_session);
SessionOperator::setSearch($updated_session);
// Return back to search page
HelperOperator::redirectTo("../views/search_view.php");
function buildQuery($searchString, $searchCategory, $sortOption, $limit = null, $offset = null)
{
    $query = null;
    // Prepare count query
    if (is_null($limit) && is_null($offset)) {
        $query = "SELECT COUNT(*) ";
    } else {
        $query = "SELECT auctions.auctionId, quantity, startPrice, reservePrice, startTime,\n            endTime, itemName, itemBrand, itemDescription, items.image, auctions.views,\n            item_categories.categoryName as subCategoryName, superCategoryName,\n            item_categories.superCategoryId, item_categories.categoryId,\n            conditionName, countryName, COUNT(DISTINCT (bids.bidId)) AS numBids,\n            COUNT(DISTINCT (auction_watches.watchId)) AS numWatches,\n            MAX(bids.bidPrice) AS highestBid,\n            case\n                when MAX(bids.bidPrice)is not null THEN MAX(bids.bidPrice)\n                else startPrice\n            end AS currentPrice ";
    }
Example #9
0
    ?>
 </a>     					</li>
            	<?php 
}
?>
      				</ul>
    			</div>
    			<div class="rightcol">
                <div id="change"><!-- this is to load ajax page when required-->

     				<p class="name" style="margin-top:-2px;"><span class="txtshd"><?php 
echo $user->fullname;
?>
</span ></p>
    <?php 
$test_record = $test->last_test_record($_SESSION['owner_id'], $_SESSION['uname'], $per_page, $pagination->offset());
if ($test_record) {
    echo '<table class="records">';
    echo "<tr style='font-size:18px;' align='center'><td>Previous Records:</td><td></td><td></td></tr>";
    echo "<tr>";
    echo "<th>";
    echo "Course";
    echo "</th>";
    echo "<th>";
    echo "Date Of Test";
    echo "</th>";
    echo "<th>";
    echo "Score Obtained";
    echo "</th>";
    echo "<th>";
    echo "Questions Correct";
Example #10
0
                                <table class="table table-striped table-bordered table-hover table-responsive">
                                <thead>
                                <tr>
                                
                                <th style="color:green">Menu Name</th>
                                <th style="color:green">Description</th>
                                <th style="color:green">Price</th>
                                <th style="color:red;" colspan="2">Actions</th>
                                </tr>
                                </thead>
                                        
                                </tbody>
                                    <?php 
$p = new Menu();
$list_of_menu = array();
$list_of_menu = $p->loadMenu($pagination->per_page, $pagination->offset());
foreach ($list_of_menu as $menu) {
    ?>
                                            <tr>
                                               
                                                <td><?php 
    echo $menu->menu_name;
    ?>
</td>
                                                <td><?php 
    echo $menu->menu_description;
    ?>
</td>
                                                <td><?php 
    echo $menu->menu_price;
    ?>
Example #11
0
<?php
require_once '../includes/initialize.php';

//Paging
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;

$per_page = 3;

$total_count = Photograph::count_all();


$pagination = new Pagination($page, $per_page, $total_count);

$sql = "select * from photographs limit {$per_page} offset {$pagination->offset()}";

$photos = Photograph::find_by_sql($sql);

include_layout_template("header.php");
?>
<p></p><a href="./admin/list_photos.php">Show Lists</a></p>
<b/>
<?
foreach ($photos as $photo): ?>
    <div style="float: left; margin-left:20px;">
        <a href="photo.php?id=<?= $photo->id ?>">
            <img src="../<? echo $photo->image_path(); ?>" width="150"/>
        </a>

        <p><?= $photo->caption ?></p>
    </div>
<?php endforeach; ?>
Example #12
0
 public static function paginer(Condition $listeConditions = NULL, $nbElementsParPage, $pageCourante = 1)
 {
     // Création d'un objet Pagination qui contiendra toutes les caractéristiques
     $pagination = new Pagination();
     // On définit ensuite les caractéristiques de la pagination
     $pagination->setNbElementsParPage($nbElementsParPage);
     $pagination->setNbElementsTotal(self::compter());
     $pagination->setPageCourante($pageCourante);
     $pagination->calculer();
     $pagination->setListeElements(self::obtenirTout($listeConditions, $pagination->offset(), $nbElementsParPage));
     return $pagination;
 }
Example #13
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 #14
0
$rel_id = get_related_sub_cat($mainct);
$tbl_name = "postcode_location";
$adjacents = 3;
$sql_search_view1 = "SELECT * FROM postcode_location INNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE postcode_location.status ='1' AND postcode_location.{$df}=" . $sub_cat_id . " AND postcode_location.id !=" . $newpostid;
//$sub_cat_id;
$total_pages = mysql_query($sql_search_view1);
$total_num_rows = mysql_num_rows($total_pages);
$total_pages = $total_num_rows;
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
// Setting a default value to the page
$per_page = 10;
// message to show per page
$pagination = new Pagination($page, $per_page, $total_num_rows);
// create an object of clas agination
// end of pagination default variables
$sql_search_view = "SELECT * FROM postcode_location INNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE postcode_location.status ='1' AND postcode_location.{$df}=" . $sub_cat_id . " AND postcode_location.id !=" . $newpostid . " LIMIT {$per_page} OFFSET {$pagination->offset()}";
$result_search_view = mysql_query($sql_search_view);
$num_rows_views = mysql_num_rows($result_search_view);
if ($num_rows_views > 0) {
    while ($row_search_view = mysql_fetch_array($result_search_view)) {
        $user_id = $row_search_view['user_id'];
        $post_id = $row_search_view['postcode_loaction_id'];
        $published_date = $row_search_view['date'];
        $town = $row_search_view['town'];
        $daysago = (strtotime($cdate) - strtotime($published_date)) / (60 * 60 * 24);
        $select_image_query = "SELECT postcode_loaction_id,file_name FROM users_images WHERE postcode_loaction_id='" . $post_id . "'  ";
        $run_image_query = mysql_query($select_image_query);
        $fetch_image_query = mysql_fetch_array($run_image_query);
        $image_name = $fetch_image_query['file_name'];
        //End Image//
        $title = $row_search_view['title'];
Example #15
0
<?php

require_once $libpath = substr(str_replace('\\', '/', __DIR__), 0, -28) . 'library/initialize.php';
if (!$session->is_logged_in()) {
    redirect_to(HOME . "login");
}
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) htmlspecialchars($_GET['page']) : 1;
// 2. records per page ($per_page)
$per_page = 7;
// 3. Find the total count of ads/photos/products
$ads = Product::find_by_field("user_id", $_SESSION['user_id']);
$total_count = 0;
if ($ads) {
    foreach ($ads as $ad) {
        $total_count++;
    }
} else {
    $ads = [];
}
$pagination = new Pagination($page, $per_page, $total_count);
$products = Product::find_by_field("user_id", $_SESSION['user_id'], ["limit" => $per_page, "offset" => $pagination->offset()]);
if (!$products) {
    $products = [];
}
include $dir_admin . 'dashboard.php';
                 <div class="col-xs-4">
                 <a href="#myModalsignup" data-toggle="modal"><button class="btn btn-success"><span class="glyphicon glyphicon-plus"></span>Add New Event</button></a>
                    <h3>Active event Lists</h3>
                <tbody>
                            <table class="table table-striped table-bordered table-hover table-responsive">
                            <thead>
                            <tr>
                            <th style="color:green">Event Name</th>
                            <th style="color:red;"colspan="2">Actions</th>
                            </tr>
                            </thead>
                            </tbody>
                                <?php 
$ev = new Event();
$list_of_event = array();
$list_of_event = $ev->loadEvent($pagination->per_page, $pagination->offset());
foreach ($list_of_event as $event) {
    ?>
                                        <tr>
                                            <td><?php 
    echo $event->event_name;
    ?>
</td>
                                               <td>
                                                  <a href="event_modal.php?event_id=<?php 
    echo $event->event_id;
    ?>
" data-toggle="modal">
                                                    <button id="btn_edit" class="btn btn-primary">
                                                      <span class="glyphicon glyphicon-edit"></span>&nbsp;Edit
                                                    </button>
Example #17
0
    }
}
$tbl_name = "postcode_location";
$adjacents = 3;
$sql_search_view1 = "SELECT *\n\nFROM postcode_location\n\nINNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE  postcode_location.status ='1'\n\nAND postcode_location.{$df} IN (" . $urlids . ") order by postcode_location.date desc";
$total_pages = mysql_query($sql_search_view1);
$total_num_rows = mysql_num_rows($total_pages);
$total_pages = $total_num_rows;
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
// Setting a default value to the page
$per_page = 10;
// message to show per page
$pagination = new Pagination($page, $per_page, $total_num_rows);
// create an object of clas agination
// end of pagination default variables
$sql_search_view = "SELECT * FROM postcode_location INNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE postcode_location.status ='1' AND postcode_location.{$df} IN (" . $urlids . ") order by postcode_location.date desc LIMIT {$per_page} OFFSET {$pagination->offset()}";
$result_search_view = mysql_query($sql_search_view);
$mappins = mysql_query($sql_search_view);
$mrk_cnt = 0;
while ($obj = mysql_fetch_array($mappins)) {
    $lat[$mrk_cnt] = $obj['lat'];
    // save the lattitude
    $lng[$mrk_cnt] = $obj['lang'];
    // save the longitude
    $inf[$mrk_cnt] = $obj['title'];
    // save the info-window
    $mrk_cnt++;
    // increment the marker counter
}
//$res->close();
// Now we have the lattitude, longitude and info-window text for each marker
Example #18
0
                   <h3>List of Town</h3>
                    <tbody>
                                <table class="table table-striped table-bordered table-hover table-responsive">
                                <thead>
                                <tr>
                                
                                <th style="color:green">Town Name</th>
                                <th style="color:red;" >Actions</th>
                                </tr>
                                </thead>
                                        
                                </tbody>
                                    <?php 
$t = new Address();
$list_of_town = array();
$list_of_town = $t->loadAllTowns($pagination->per_page, $pagination->offset());
foreach ($list_of_town as $town) {
    ?>
                                            <tr>
                                               
                                                <td><?php 
    echo $town->town_name;
    ?>
</td>
                                                <td>
                                                  <a href="town_modal.php?town_id=<?php 
    echo $town->town_id;
    ?>
" data-toggle="modal">
                                                <button id="btn_edit" class="btn btn-primary">
                                                    <span class="glyphicon glyphicon-edit"></span>&nbsp;Edit
                 <hr/>  
                     <tbody>
                            <table class="table table-striped table-bordered table-hover table-responsive">
                            <thead>
                            <tr>
                            <th style="color:green">Customer Name</th>
                            <th style="color:green">Email Address</th>
                            <th style="color:green">Message</th>
                            <th style="color:red;"colspan="2">Actions</th>
                            </tr>
                            </thead>
                            </tbody>
                                <?php 
$ev = new Comments();
$list_of_comment = array();
$list_of_comment = $ev->loadComments($pagination->per_page, $pagination->offset());
foreach ($list_of_comment as $comm) {
    ?>
                                        <tr>
                                            <td><?php 
    echo $comm->customer_name;
    ?>
</td>
                                            <td><?php 
    echo $comm->email;
    ?>
</td>
                                            <td><?php 
    echo $comm->message;
    ?>
</td>
Example #20
0
<?php

//pagination code
$current_page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$per_page = 20;
$total_count = $route_object->count_all();
$pagination = new Pagination($current_page, $per_page, $total_count);
$sql = "SELECT * FROM routes";
$sql .= " LIMIT " . $per_page;
$sql .= " OFFSET " . $pagination->offset();
$routes = $route_object->find_by_sql($sql);
//check login
if ($session->is_logged_in()) {
    if ($session->object_type == 6) {
        //commuter
        $user = $commuter_object->find_by_id($_SESSION['id']);
        $profile_picture = $photo_object->get_profile_picture($session->object_type, $user->id);
    }
}
                   <a href="#myModalsignup" data-toggle="modal"><button class="btn btn-success"><span class="glyphicon glyphicon-plus"></span>Add New Member</button></a>
                       <h3>Active member Lists</h3>
                    <tbody>
                                <table class="table table-striped table-bordered table-hover table-responsive">
                                <thead>
                                <tr>
                                
                                <th style="color:green">Member Name</th>
                                <th style="color:red;" colspan="2">Actions</th>
                                </tr>
                                </thead>
                                </tbody>
                                    <?php 
$add = new Member();
$list_of_member = array();
$list_of_member = $add->loadMember($pagination->per_page, $pagination->offset());
foreach ($list_of_member as $member) {
    ?>
                                            <tr>
                                               
                                                <td><?php 
    echo $member->member_name;
    ?>
</td>
                                                <td>
                                                  <a href="../functions/inactive_teamMember.php?id=<?php 
    echo $member->member_id;
    ?>
">
                                                <button class="btn btn-danger"><span class="glyphicon glyphicon-remove-circle">
                                                 </span>&nbsp;Set to Inactive</button></a>
 public static function find_all_pagination($page, $per_page, $total_count, $myid)
 {
     $pagination = new Pagination($page, $per_page, $total_count);
     return self::find_by_sql("SELECT *\n\t\tFROM exercise\n\t\tHAVING plan_id != {$myid}\n\t\tORDER BY latitude\n\t\tLIMIT {$per_page}\n\t\tOFFSET {$pagination->offset()}");
 }
                   <h3>List of Barangay</h3>
                    <tbody>
                                <table class="table table-striped table-bordered table-hover table-responsive">
                                <thead>
                                <tr>
                                
                                <th style="color:green">Barangay Name</th>
                                <th style="color:red;" >Actions</th>
                                </tr>
                                </thead>
                                        
                                </tbody>
                                    <?php 
$b = new Address();
$list_of_brgy = array();
$list_of_brgy = $b->loadAllBarangays($pagination->per_page, $pagination->offset());
foreach ($list_of_brgy as $brgy) {
    ?>
                                            <tr>
                                               
                                                <td><?php 
    echo $brgy->brgy_name;
    ?>
</td>
                                                <td>
                                                  <a href="barangay_modal.php?brgy_id=<?php 
    echo $brgy->brgy_id;
    ?>
" data-toggle="modal">
                                                <button id="btn_edit" class="btn btn-primary">
                                                    <span class="glyphicon glyphicon-edit"></span>&nbsp;Edit
Example #24
0
<?php

require_once $libpath = substr(str_replace('\\', '/', __DIR__), 0, -29) . 'library/initialize.php';
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) htmlspecialchars($_GET['page']) : 1;
// 2. records per page ($per_page)
$per_page = 6;
// 3. total record count ($total_count)
$total_count = Product::count_all();
$pagination = new Pagination($page, $per_page, $total_count);
$products = Product::find_all(["limit" => $per_page, "offset" => $pagination->offset()]);
include $dir_public . 'index.php';
Example #25
0
        case $sec:
            $sec_name = $s['title'];
            $QNA->section = $s['id'];
            $qs = $QNA->get_questions();
            $count = count($qs);
            $pag = new Pagination($count, $cp, $rpp);
            $offset = $pag->offset();
            $qs = $QNA->get_questions($rpp, $offset);
            break 2;
            // breaks out of the two casses (foreach and switch)
        // breaks out of the two casses (foreach and switch)
        default:
            $qs = $QNA->get_questions();
            $count = count($qs);
            $pag = new Pagination($count, $cp, $rpp);
            $offset = $pag->offset();
            $qs = $QNA->get_questions($rpp, $offset);
            $sec_name = 'All';
            break;
    }
}
$pageTitle = "Stories";
$sec = "questions";
include ROOT_PATH . 'inc/head.php';
?>
<body>
	<div class="ui container section">
		<div class="ui large search" id="ent">
			<div class="ui icon input">
				<input type="text" autocomplete="off" id="sec_ent">
			</div>
$order_name = !empty($_GET["order_name"]) ? $_GET["order_name"] : 'id';
$order_type = !empty($_GET["order_type"]) ? $_GET["order_type"] : 'ASC';
//echo get_where_string($class_name);
$page = !empty($_GET['page']) ? (int) $_GET["page"] : 1;
$per_page = 20;
$where = get_where_string($class_name);
$total_count = $class_name::count_all_where($where);
$pagination = new Pagination($page, $per_page, $total_count);
require_once LIB_PATH . DS . 'download' . DS . 'download_csv.php';
$sql = "SELECT * FROM {$table_name} ";
$sql .= " " . get_where_string($class_name);
if (isset($order_name)) {
    $sql .= " ORDER BY {$order_name} {$order_type} ";
}
$sql .= "LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
//echo "<p>$sql</p>";
//unset($_GET);
$result_class = $class_name::find_by_sql($sql);
$query_string = remove_get(array('view', 'page'));
$view_full_table = !empty($_GET) ? (int) $_GET["view"] : 0;
if ($view_full_table == 1) {
    $page_link_view = $class_name::$page_manage . $query_string . "page=" . u($page) . "&view=" . u(0);
    $page_link_text = $class_name::$page_name . " short view";
    //$add_view="&view=".u(1);
    $offset = "col-md-offset-2";
} else {
    $page_link_view = $class_name::$page_manage . $query_string . "page=" . u($page) . "&view=" . u(1);
    $page_link_text = $class_name::$page_name . " full view";
    $offset = '';
}
Example #27
0
 public function findWithPaginate($table, $page, $per_page)
 {
     $total = $this->countAll($table)->total;
     $p = new Pagination($page, $per_page, $total);
     $sql = "SELECT * FROM {$table} WHERE deleted_at IS NULL ORDER BY created_at DESC LIMIT :per_page OFFSET :offset";
     //
     $q = $this->conn->prepare($sql);
     $q->execute(array(':per_page' => $per_page, ':offset' => $p->offset()));
     $count = $q->rowCount();
     if ($count > 0) {
         while ($r = $q->fetch(PDO::FETCH_OBJ)) {
             $data[] = $r;
         }
         $data[] = $p;
         return $data;
     } else {
         return false;
     }
 }