S
S
Sergey2019-11-05 12:51:00
css
Sergey, 2019-11-05 12:51:00

How to style table cells based on their content?

Good day! Tell me, please, nearby))). There is a booking table (a week is displayed in the visible area). A JS timer is attached to it and, in fact, the days "go", so just specifying the style will not work, because today it is, for example, Sunday, and tomorrow is Monday, and every time you change, even I understand that it's crazy)))). Is it somehow possible to set classes for weekends in this part of the code, so that from CSS you can set a red frame for the weekend, so that it is always on them? Or if it’s impossible from this part of the code, tell me, I’ll add it.

<?php 
$array = get_cforms_entries();   /* all data, no filters */

$months = array( 1 => 'Января' , 'Февраля' , 'Марта' , 'Апреля' , 'Мая' , 'Июня' , 'Июля' , 'Августа' , 'Сентября' , 'Октября' , 'Ноября' , 'Декабря' );
$days = array( 1 => 'Понедельник' , 'Вторник' , 'Среда' , 'Четверг' , 'Пятница' , 'Суббота' , 'Воскресенье');
?>
<div class="table-responsive">
  <table class="table">
  <tr>
    <th>Дата</th><th>12:00</th><th>13:30</th><th>15:00</th><th>16:30</th><th>18:00</th><th>19:30</th><th class="21time">21:00</th><th class="22 time">22:30</th><th class="23 time">00:00</th>
  </tr>
<tr><?php 
    $day = date('d ' . $months[date( 'n',strtotime("0 day"))],strtotime("0 day")); 
    $day1 = date($days[date('N', strtotime("0 day") )]);
    $id_broni = date('dm', strtotime("0 day") );
    if($day1 == 'Суббота' or $day1 == 'Воскресенье') {$sum = get_post_meta( $post->ID, 'cost_night', true ).'р';} else {$sum = get_post_meta( $post->ID, 'cost_day', true ).'р';}
  ?>
  <td><?php echo $day; ?><br /><?php echo $day1; ?></td>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TCloud, 2019-11-05
@Sergey772

.red-border {
  border: 1px solid red;
}

php
if($day1 == 'Суббота' or $day1 == 'Воскресенье') {
  // some else code here...
  echo "<td class='red-border'>...</td>";
} else {
  // some else code here...
  echo "<td>...<td>"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question