У меня есть проблема в цвете массива, определяющая номер префикса для отображения в содержимом таблицы, я попробовал приведенную ниже кодировку, чтобы сделать это:
<div id="collapse4" class="body">
<table id="" class="table table-bordered table-condensed table-hover table-striped dataTable">
<thead>
<tr>
<th style='width:7%'>No</th>
<th class='filter_text_field'>Name</th>
<th class='filter_text_field'>Folder Location</th>
<th class='filter_text_field'>Category</th>
<th class='filter_text_field'>Request By</th>
<th class='filter_text_field'>Date Request</th>
<th class='filter_text_field'>Status</th>
<?php if ($module_user_permission['edit'] == 1) { ?>
<th style='width:15%'>Action</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$colors = array (
1 => "blue", //--> for all colors within the range of 100-199
2 => "red", //--> for all colors within the range of 200-299
3 => "yellow", //--> for all colors within the range of 300-399
4 => "purple", //--> for all colors within the range of 400-499
5 => "green" //--> for all colors within the range of 500-599
);
$stmt = 'Rules:<br>
1 => "blue" //--> for all colors within the range of 100-199
2 => "red" //--> for all colors within the range of 200-299
3 => "yellow" //--> for all colors within the range of 300-399
4 => "purple" //--> for all colors within the range of 400-499
5 => "green" //--> for all colors within the range of 500-599
';
foreach($rs_wtp['name'] as $name => $valuetocheck){
$check = $valuetocheck[0];
$stmt .= '<td style="color:';
foreach ($colors as $key => $color){
if($check == $key){
$stmt .= $color;
}
}$stmt .= ';">'.$valuetocheck.'</td>';
}
echo $stmt;
$sql_wtp = "select * from filing_code_management";
$query_wtp = db_conn_select($sql_wtp);
foreach ($query_wtp as $rs_wtp) {
if ($rs_wtp['status'] == 1) {
$active = 'Active';
} elseif ($rs_wtp['status'] == 0) {
$active = 'Inactive';
}
echo "<tr>";
echo "<td>" . (++$no) . "</td>";
echo "<td>" . $rs_wtp['name'] . "</td>";
echo "<td>" . $rs_wtp['folder_location'] . "</td>";
echo "<td>" . $rs_wtp['category'] . "</td>";
echo "<td>" . $rs_wtp['request_by'] . "</td>";
echo "<td>" . $rs_wtp['date_request'] . "</td>";
echo "<td>" . $active . "</td>";
if ($module_user_permission['edit'] == 1) {
echo '<td><a href="#wtp_modal" onclick="select_(\'' . md5($rs_wtp['id'].$md5) . '\',\'wtp_content\')" data-toggle="modal" data-original-title="Help" class="btn btn-sm btn-primary" data-color-format="hex">Update</a>';
if ($rs_wtp['status'] == 1) {
echo '<a onclick="delete_(\'' . md5($rs_wtp['id'].$md5) . '\',1)" class="btn btn-sm btn-primary" data-color-format="hex">Deactivate</a>';
} elseif ($rs_wtp['status'] == 0) {
echo '<a onclick="delete_(\'' . md5($rs_wtp['id'].$md5) . '\',0)" class="btn btn-sm btn-primary" data-color-format="hex">Activate</a>';
}
echo '</td>';
}
echo "</tr>";
}
?>
</tbody>
</table>
</div>
В выходных данных мне показано следующее изображение:
Выход1
На самом деле я хочу вывод, как показано на рисунке ниже. Я использую программное обеспечение для рисования, чтобы редактировать его, потому что он может легко дать вам знать, что я хочу получить на выходе. Если результат успешной работы может поставить другой цвет на echo "". $ rs_wtp ['name']. ""; эхо "". $ rs_wtp ['folder_location']. ""; :
Вывод 2
Я застрял в этой проблеме несколько дней. Надеюсь, что кто-то может подсказать мне, в какой части я ошибаюсь. Спасибо, спаси мой день.