B
B
bekhrouzb2021-12-10 12:24:17
AJAX
bekhrouzb, 2021-12-10 12:24:17

How to change cell color by status?

Hello everyone

, I have a table, first I add an incident to the table, then when I need to change the status of the incident to, "Successfully closed", "In progress", etc., and now I want to change the color of the line when choosing a certain status, tell me please how to implement the script

<table>
           <thead>
                    <tr>
                        <th>ID</th>
                        <th>Инцидент добавлен</th>
                        <th>Агент</th>
                        <th>Количество заявок</th>
                        <th>Номера терминалов</th>
                        <th>Примечание</th>
                        <th>Статус</th>
                        <th>Регион</th>
                        <th>Дата изменения инцидента</th>
                        <th>Специалист</th>
                        <th>Редактирование</th>
                    </tr>
            </thead>
            <tbody>
                    <?php foreach($tasks as $task):?> //вывожу циклом данные из бд
 
                    <tr>
                        <td><?= $task["id"]; ?></td>
                        <td><?= $task["date"]; ?></td>
                        <td><?= $task["title"]; ?></td>
                        <td><?= $task["content"]; ?></td>
                        <td><?= $task["amount"]; ?></td>
                        <td><?= $task["comment"]; ?></td>
                        <td><?= $task["status"]; ?></td>
                        <td><?= $task["region"]; ?></td>
                        <td><?= $task["change_time"]; ?></td>
                        <td><?= $task["spe******t"]; ?></td>
 
                        <td class="btn-all">
                            <a href="show.php?id=<?= $task['id'];?>" class="btn-show">Show</a>
                            <a href="edit.php?id=<?= $task['id'];?>" class="btn-edit">Edit</a>
                            <a onclick="return confirm('Вы уверены, что хотите удалить инцидент?');" href="delete.php?id=<?= $task['id'];?>" class="btn-delete">Delete</a>
                        </td>
                    </tr>
 
                    <?php endforeach; ?>
        </tbody>
</table>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
Undefended, 2021-12-10
@osvex

Perhaps I suggest a crutch. Don't hit (

<?php
if($task["status"]=="Успешно-закрыт"){
$color = "green";
}
elseif($task["status"]=="В процессе"){
$color = "yellow";
}
?>

<td><font color="<?php echo $color; ?>"><?php echo $task["status"]; ?></td>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question