Departments

<?php
$limit = 10; //how many items to show per page
$page = isset($_GET['page']) ? $_GET['page'] : "";

if($page) {
$start = ($page - 1) * $limit; //first item to display on this page
}
else {
$start = 0;
}
global $base_url;
$query = db_query("SELECT * FROM dbc_department WHERE status=1 ");
if($query->fetchAll()){
$result = db_query("SELECT * FROM dbc_department WHERE status =1 ORDER BY weight LIMIT {$start},{$limit}");
foreach($result as $staff)
{
?>

<?php
}

$query = db_query("SELECT * FROM dbc_department ");
$count = 0;
foreach($query as $records)
{
$total = $count++;
}
if ($page == 0)
$page = 1;
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1

$pagination = "";
if($lastpage > 1)
{
$pagination .= "";
$pagination .= "";

$pagination .= "

    ";
    if ($page > 1){
    $pagination.= "
  • « first
  • ";
    $pagination.= "

    ";
    }
    for ($counter=1; $counter<=$lastpage; $counter++) {
    //$pagination.="

  • $i
  • ";
    if ($counter == $page){
    $pagination.= "

  • $counter
  • ";
    }
    else{
    $pagination.= "

  • $counter
  • ";
    }
    }
    if ($page < $lastpage) {
    $pagination.= "

    ";
    $pagination.= "

  • last »
  • ";
    }
    $pagination .= "

";
$pagination.= "";
$pagination.= "";
}

echo $pagination;
}
else{
echo 'No records found';
}
?>
&nbsp
&nbsp
&nbsp
&nbsp
&nbsp
&nbsp
&nbsp
&nbsp
&nbsp