datalist vehicle brand model
unknown
php
2 years ago
4.6 kB
2
Indexable
Never
<?php include('db/conn.php'); include('admin_functions.php'); include('admin_model.php'); $tablename = "vehicle_brand_model_lookup"; $requestData = $_REQUEST; $vehicle_id = $_REQUEST['vehicle_id']; $columns = array( 0 => 'id', ); $sql = "SELECT vehicle_brand_model_lookup.id, vehicle_brand_model_lookup.brand_id, vehicle_brand_model_lookup.model_id FROM vehicle_brand_model_lookup INNER JOIN vehicle_brand_lookup ON (vehicle_brand_model_lookup.brand_id = vehicle_brand_lookup.id) INNER JOIN vehicle_model_lookup ON (vehicle_brand_model_lookup.model_id = vehicle_model_lookup.id)"; $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_model_lookup.id, vehicle_brand_model_lookup.brand_id, vehicle_brand_model_lookup.model_id, vehicle_brand_lookup.vehicle_brand, vehicle_model_lookup.vehicle_model FROM vehicle_brand_model_lookup INNER JOIN vehicle_brand_lookup ON (vehicle_brand_model_lookup.brand_id = vehicle_brand_lookup.id) INNER JOIN vehicle_model_lookup ON (vehicle_brand_model_lookup.model_id = vehicle_model_lookup.id) 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_id = $row['brand_id']; $vehicle_model_id = $row['model_id']; $vehicle_brand = $row['vehicle_brand']; $vehicle_model = $row['vehicle_model']; $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>"; $nestedData[] = "<div align='left' style='display: inline-block; white-space: nowrap;' >" . $vehicle_model . "</div>"; $key = "cube123"; $menu = 126; $menu = selaktutup($key,$menu); $menu = rawurlencode($menu); $menu2 = 127; $menu2 = selaktutup($key,$menu2); $menu2 = rawurlencode($menu2); $menu3 = 128; $menu3 = selaktutup($key,$menu3); $menu3 = rawurlencode($menu3); $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='edit_vehicle_brand' value='EDIT' style='border-radius:10px;' class='btn btn-success fontYantra''>EDIT</a> <a href='index.php?msa=$menu2&id=$id' id='assign_vehicle_model' value='REMOVE' style='border-radius:10px;' class='btn btn-danger fontYantra''>REMOVE</a> </div>"; $nestedData[] = "<div align='left' style='display: inline-block; white-space: nowrap;'> <a href='index.php?msa=$menu3&id=$id' id='edit_vehicle_brand' value='ADD VEHICLE DETAILS' style='border-radius:10px;' class='btn btn-info fontYantra''>ADD VEHICLE DETAILS</a> </div>"; $data[] = $nestedData; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>