PATH:
home2
/
pbkvidya
/
public_html
/
admin
/
Editing: view_data.php
<?php /* Database connection */ include_once 'connect.php'; // storing request (ie, get/post) global array to a variable $requestData= $_REQUEST; $id1=$_POST['id']; //Banners area begin if($id1=='banner'){ $columns = array( // datatable column index => database column name 0 =>'banner_id', 1 =>'banner_image' ); // getting total number records without any search $sql = "SELECT banner_id, banner_image "; $sql.=" FROM tbl_banners"; $query=mysqli_query($con, $sql) or die("view_data.php: get banners"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = "SELECT banner_id, banner_image "; $sql.=" FROM tbl_banners WHERE 1=1"; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND ( banner_title LIKE '".$requestData['search']['value']."%' "; $sql.=" OR banner_id LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($con, $sql) or die("view_data.php: get banners"); $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */ $query=mysqli_query($con, $sql) or die("view_data.php: get banners"); $data = array(); $i=1; while( $row=mysqli_fetch_array($query) ) { // preparing an array $ed="<a href='update_banner.php?id=" . $row['banner_id'] ." ' class='sb2-2-1-edit'><i class='fa fa-pencil-square-o' title='Edit'></i></a>"; $de="<a href='#myModal' class='sb2-2-1-delete' data-toggle='modal'><i class='fa fa-trash-o delete' data-id='".$row["banner_id"]."' title='Delete'> </i></a>"; $nestedData=array(); $nestedData[] = $i; $nestedData[] = "<img src='".$row["banner_image"]."' height='80px'>"; $nestedData[] = $ed; $nestedData[] = $de; $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 } //End Banners //notifications area begin if($id1=='notification'){ $columns = array( // datatable column index => database column name 0 =>'notification_id', 1 =>'notification_name', 2 =>'notification_link' ); // getting total number records without any search $sql = "SELECT notification_id, notification_name, notification_link"; $sql.=" FROM tbl_notification"; $query=mysqli_query($con, $sql) or die("view_data.php: get notifications"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = "SELECT notification_id, notification_name, notification_link "; $sql.=" FROM tbl_notification WHERE 1=1"; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND ( notification_name LIKE '".$requestData['search']['value']."%' "; $sql.=" OR notification_id LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($con, $sql) or die("view_data.php: get notifications"); $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */ $query=mysqli_query($con, $sql) or die("view_data.php: get notifications"); $data = array(); $i=1; while( $row=mysqli_fetch_array($query) ) { // preparing an array $ed="<a href='update_notification.php?id=" . $row['notification_id'] ." ' class='sb2-2-1-edit'><i class='fa fa-pencil-square-o' title='Edit'></i></a>"; $de="<a href='#myModal' class='sb2-2-1-delete' data-toggle='modal'><i class='fa fa-trash-o delete' data-id='".$row["notification_id"]."' title='Delete'> </i></a>"; $nestedData=array(); $nestedData[] = $i; $nestedData[] = $row["notification_name"]; $nestedData[] = $row["notification_link"]; $nestedData[] = $ed; $nestedData[] = $de; $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 } //End notifications //Gallery area begin if($id1=='gallery'){ $columns = array( // datatable column index => database column name 0 =>'gallery_id', 1 => 'gallery_image' ); // getting total number records without any search $sql = "SELECT gallery_id, gallery_image "; $sql.=" FROM tbl_gallery"; $query=mysqli_query($con, $sql) or die("view_data.php: get gallery"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = "SELECT gallery_id, gallery_image "; $sql.=" FROM tbl_gallery WHERE 1=1"; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND (gallery_image LIKE '".$requestData['search']['value']."%' "; $sql.=" OR gallery_id LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($con, $sql) or die("view_data.php: get gallery"); $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */ $query=mysqli_query($con, $sql) or die("view_data.php: get gallery"); $data = array(); $i=1; while( $row=mysqli_fetch_array($query) ) { // preparing an array $ed="<a href='update_gallery.php?id=" . $row['gallery_id'] ." ' class='sb2-2-1-edit'><i class='fa fa-pencil-square-o' title='Edit'></i></a>"; $de="<a href='#myModal' class='sb2-2-1-delete' data-toggle='modal'><i class='fa fa-trash-o delete' data-id='".$row["gallery_id"]."' title='Delete'> </i></a>"; $nestedData=array(); $nestedData[] = $i; $nestedData[] = "<img src='".$row["gallery_image"]."' height='80px'>"; $nestedData[] = $ed; $nestedData[] = $de; $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 } //End Gallery //generalinfos area begin if($id1=='generalinfo'){ $columns = array( // datatable column index => database column name 0 =>'generalinfo_id', 1 =>'affiliation_number', 1 =>'school_name', 1 =>'school_code', 1 =>'school_address', 1 =>'principal_name', 1 =>'principal_qualification', 1 =>'school_email', 1 =>'school_contact', ); // getting total number records without any search $sql = "SELECT `generalinfo_id`, `affiliation_number`, `school_name`, `school_code`, `school_address`, `principal_name`, `principal_qualification`, `school_email`, `school_contact` "; $sql.=" FROM tbl_generalinfo"; $query=mysqli_query($con, $sql) or die("view_data.php: get generalinfos"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = "SELECT `generalinfo_id`, `affiliation_number`, `school_name`, `school_code`, `school_address`, `principal_name`, `principal_qualification`, `school_email`, `school_contact`"; $sql.=" FROM tbl_generalinfo WHERE 1=1"; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND ( school_name LIKE '".$requestData['search']['value']."%' "; $sql.=" OR generalinfo_id LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($con, $sql) or die("view_data.php: get generalinfos"); $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */ $query=mysqli_query($con, $sql) or die("view_data.php: get generalinfos"); $data = array(); $i=1; while( $row=mysqli_fetch_array($query) ) { // preparing an array $ed="<a href='update_generalinfo.php?id=" . $row['generalinfo_id'] ." ' class='sb2-2-1-edit'><i class='fa fa-pencil-square-o' title='Edit'></i></a>"; $de="<a href='#myModal' class='sb2-2-1-delete' data-toggle='modal'><i class='fa fa-trash-o delete' data-id='".$row["generalinfo_id"]."' title='Delete'> </i></a>"; $nestedData=array(); $nestedData[] = $i; $nestedData[] = $row["affiliation_number"]; $nestedData[] = $row["school_name"]; $nestedData[] = $row["school_code"]; $nestedData[] = $row["school_address"]; $nestedData[] = $row["principal_name"]; $nestedData[] = $row["principal_qualification"]; $nestedData[] = $row["school_email"]; $nestedData[] = $row["school_contact"]; $nestedData[] = $ed; $nestedData[] = $de; $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 } //End generalinfos //TC area begin if($id1=='tc'){ $columns = array( // datatable column index => database column name 0 =>'tc_id', 1 =>'tc_link' ); // getting total number records without any search $sql = "SELECT tc_id, tc_link "; $sql.=" FROM tbl_tc"; $query=mysqli_query($con, $sql) or die("view_data.php: get tc"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = "SELECT tc_id, tc_link "; $sql.=" FROM tbl_tc WHERE 1=1"; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND ( tc_link LIKE '".$requestData['search']['value']."%' "; $sql.=" OR tc_id LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($con, $sql) or die("view_data.php: get tc"); $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */ $query=mysqli_query($con, $sql) or die("view_data.php: get tc"); $data = array(); $i=1; while( $row=mysqli_fetch_array($query) ) { // preparing an array $ed="<a href='update_tc.php?id=" . $row['tc_id'] ." ' class='sb2-2-1-edit'><i class='fa fa-pencil-square-o' title='Edit'></i></a>"; $de="<a href='#myModal' class='sb2-2-1-delete' data-toggle='modal'><i class='fa fa-trash-o delete' data-id='".$row["tc_id"]."' title='Delete'> </i></a>"; $nestedData=array(); $nestedData[] = $i; $nestedData[] = $row["tc_link"]; $nestedData[] = $ed; $nestedData[] = $de; $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 } //End tc ?>
SAVE
CANCEL