ok
Direktori : /proc/self/root/home2/selectio/www/y1jobportal.in/admin/data-tables/ |
Current File : //proc/self/root/home2/selectio/www/y1jobportal.in/admin/data-tables/subcategory-data-table.php |
<?php include("../api/config/config.php"); $requestData = $_REQUEST; $condition=''; $status = $_POST['status']; if(isset($status) && $status!=""){ $condition.=" and sub_category.status = '".$status."' "; } if(isset($_POST['category_id']) && $_POST['category_id']!=""){ $condition.=" and sub_category.category_id = '".$_POST['category_id']."' "; } /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'id', 2 =>'id', 3 => 'id', ); /*Fetch Filter Data Start*/ $sql="SELECT sub_category.*,category.name as category_name FROM `sub_category` inner join category on sub_category.category_id=category.id where 1=1 $condition"; if( !empty($requestData['search']['value']) ) { $sql.=" AND ( sub_category.name LIKE '%".$requestData['search']['value']."%' )"; } $statement = $pdo->prepare($sql); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalFiltered = $statement->rowCount(); $totalData = $statement->rowCount(); /*Fetch Filter Data End*/ $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; $statement = $pdo->prepare($sql); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $data = array(); $i=$requestData['start']+1; foreach($query as $row ) { // preparing an array $nestedData=array(); $action= "<div class='text-center'><div class='btn-group'>"; $action.="<a style='padding: 0px 0px 0px 5px; height: 30px; margin-right: 3px;' href='subcategory-edit.php?id=".$row["id"]."' title='Edit Subcategory' class='tip btn btn-warning btn-xs'> <i class='bi bi-pencil'></i> </a> "; $action.=" <button style='padding: 0px 0px 0px 5px; height: 30px; margin-right: 3px;' title='Delete District Details' onClick='delete_district(".$row["id"].")' class='tip btn btn-danger btn-xs'> <i class='bi bi-trash3'></i> </button>"; $action.="</div></div>"; $details1 = '<a ><b>'.$row['name'].'</b></a>'; $details2 = '<a ><b>'.$row['category_name'].'</b></a>'; if($row['status']=="1"){ $status="<span class='span-success'> Active </span>"; } else{ $status="<span class='span-danger'> In-Active </span>"; } $nestedData[] = $action; $nestedData[] = $i; $nestedData[] = $details1; $nestedData[] = $details2; $nestedData[] = $status; $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. "recordsTotal" => intval( $totalData ), // total number of records "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData "data" => $data // total data array ); echo json_encode($json_data); // send data as json format ?>