datalist

mail@pastecode.io avatar
unknown
php
2 years ago
3.0 kB
1
Indexable
Never
<?php
	include('db/conn.php');
    include('admin_functions.php');
    include('admin_model.php');
	
	$tablename 		= "vehicle_brand_lookup";
	$requestData	= $_REQUEST;
	
	$vehicle_id		= $_REQUEST['vehicle_id'];
	
	$columns = array(
					0 	=>	'id',
					);

	
	$sql = "SELECT
				vehicle_brand_lookup.id,
				vehicle_brand_lookup.vehicle_brand
			FROM
				vehicle_brand_lookup";
	
	$rs = $conn->query($sql) or die($conn->error);	
	while($row = $rs->fetch_assoc()) 
	{
		
	}
	
	$query 			= $conn->query($sql);	
	$totalData 		= $query->num_rows;
	$totalFiltered 	= $totalData;  
	
	$sql = "SELECT
				vehicle_brand_lookup.id,
				vehicle_brand_lookup.vehicle_brand
			FROM
				vehicle_brand_lookup
				where 1=1";	
		
	$search_array = array(
						'',
						'',
						'',
						'',
						);
	
	if( !empty($requestData['search']['value']) ) {
		$sql.=" AND ( id LIKE '%".$requestData['search']['value']."%' ";
		
		foreach ($search_array as $key => $column) {
			$sql.=" OR $column LIKE '%".$requestData['search']['value']."%' ";
		}
		
		$sql.=" OR status LIKE '".$requestData['search']['value']."%' )";
	}
		
    $query			= $conn->query($sql) or die($conn->error);
	$totalData 		= $query->num_rows;
	$totalFiltered 	= $totalData;  
    
    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
    $query	= $conn->query($sql);
	
	//print $sql;
	
	$counter 	= 0;
	$data 		= array();																				
    while($row = $query->fetch_assoc()) 
    {
		$counter++;
		$id 					= $row['id'];	
		$vehicle_brand			= $row['vehicle_brand'];
		
		$nestedData		= array();
		$nestedData[] 		= "<div align='left' 
									style='display: inline-block;
									white-space: nowrap;' >" . $id . "</div>";			
		
		$nestedData[] 		= "<div align='left' 
									style='display: inline-block;
									white-space: nowrap;' >" . $vehicle_brand . "</div>";
			
		$key	= "cube123";
		
		$menu 	= 111;
		$menu 	= selaktutup($key,$menu);
		$menu 	= rawurlencode($menu);
		
		$menu 	= 112;
		$menu 	= selaktutup($key,$menu);
		$menu 	= rawurlencode($menu);
		
		$id 	= selaktutup($key,$id);
		$id 	= rawurlencode($id);		
		
		$nestedData[] 		= 	"<div align='left' 
									style='display: inline-block;
									white-space: nowrap;'>
									
										<a href='index.php?msa=$menu&id=$id' 
											id='update_data' 
											value='UPDATE' 
											style='border-radius:10px;'
											class='btn btn-success fontYantra''>EDIT VEHICLE BRAND</a>
								</div>";			
		 
		 $data[] = $nestedData;
	}

    $json_data = array(
    			"draw"           	=> intval( $requestData['draw'] ),  
    			"recordsTotal"    	=> intval( $totalData ),  				
    			"recordsFiltered" 	=> intval( $totalFiltered ), 			 
    			"data"            	=> $data   								
    			);

    echo json_encode($json_data);
?>