File: /home/imensosw/www/imenso.co/demo/claapp/admin/search.php
<?php
include_once("../config/config.php");
include_once(BASIC_PATH."model/admin.php");
if(isset($_POST['page'])){
//Include pagination class file
include(BASIC_PATH.'config/Pagination.php');
//Include database configuration file
$start = !empty($_POST['page'])?$_POST['page']:0;
$limit = 10;
//set conditions for search
$whereSQL = $orderSQL = '';
$keywords = $_POST['keywords'];
if(!empty($keywords)){
$whereSQL.= " where name LIKE '%".$keywords."%'";
}
$resultNum = $crud->getData("select count(*) as postNum from users $whereSQL");
$rowCount = $resultNum[0]['postNum'];
$pagConfig = array(
'currentPage' => $start,
'totalRows' => $rowCount,
'perPage' => $limit,
'link_func' => 'searchFilter'
);
$pagination = new Pagination($pagConfig);
$query="select * from users $whereSQL order by id desc limit $start,$limit";
$result=$crud->getData($query);
if($result)
{
for($i=0;$i<count($result);$i++)
{
$role="User";
if($result[$i]['appadmin']==1)
{
$role="Admin";
}
else if($result[$i]['claadmin']==1)
{
$role="Manager";
}
else if($result[$i]['clacreator']==1)
{
$role="Creator";
}
echo '<tr>';
echo '<td><span class="Name">'.$result[$i]['name'].'</span></td>';
echo '<td><span class="Email">'.$result[$i]['email'].'</span></td>';
echo '<td><span class="Role">'.$role.'</span></td>';
echo '<td class="text-center"><button class="btn btn-default m_l10 edit_user" data-id="'.$result[$i]['id'].'">Edit</button>
</td></tr>';
}
echo $pagination->createLinks();
}
}?>