Por ejemplo. si el Equipo muestra el status "DISPONIBLE" esté en verde o si muestra el status "OCUPADA" este en rojo, etc.
Adjunto código php:
Código PHP :
<?php include('db.php'); include('function.php'); $query = ''; $output = array(); $query .= "SELECT * FROM equipos "; if(isset($_POST["search"]["value"])) { $query .= 'WHERE clave_ogo LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR marca LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR modelo LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR serie LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR m_cpu LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR vel_cpu LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR cap_hdd LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR cant_ram_asign LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR memoria_video LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR s_o LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR usuario LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR empresa LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR status LIKE "%'.$_POST["search"]["value"].'%" '; } if(isset($_POST["order"])) { $query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $query .= 'ORDER BY clave_ogo ASC '; } if($_POST["length"] != -1) { $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $statement = $connection->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $data = array(); $filtered_rows = $statement->rowCount(); foreach($result as $row) { $image = ''; if($row["image"] != '') { $image = '<img src="upload/'.$row["image"].'" class="img-thumbnail" width="50" height="35" />'; } else { $image = ''; } $sub_array = array(); $sub_array[] = $image; $sub_array[] = $row["clave_ogo"]; $sub_array[] = $row["marca"]; $sub_array[] = $row["modelo"]; $sub_array[] = $row["serie"]; $sub_array[] = $row["m_cpu"]; $sub_array[] = $row["vel_cpu"]; $sub_array[] = $row["cap_hdd"]; $sub_array[] = $row["cant_ram_asign"]; $sub_array[] = $row["memoria_video"]; $sub_array[] = $row["usuario"]; $sub_array[] = $row["empresa"]; $sub_array[] = $row["status"]; $sub_array[] = '<button type="button" name="update" id="'.$row["id"].'" class="glyphicon glyphicon-pencil btn btn-primary btn-xs update"></button>'; $sub_array[] = '<button type="button" name="delete" id="'.$row["id"].'" class="glyphicon glyphicon-trash btn btn-danger btn-xs delete"></button>'; $data[] = $sub_array; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $filtered_rows, "recordsFiltered" => get_total_all_records(), "data" => $data ); echo json_encode($output); ?>
Les adjunto una captura de pantalla de la tabla:
Muchas gracias de antemano.
Saludos.