1. PHP / Говнокод #16612

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    for ($j=1; $j<8; $j++) {
        $up = "";
        $down = "";
        for ($i=1; $i<7; $i++) {
            if (($i==4)&&($j==4)) {
                $up = $up.'<td class="simp" colspan="2" rowspan="4">Военная<br>Подготовка</td>';
                continue;
            }
            if (($i==4)&&($j>3)&&($j<6)) {
                continue;
            }
            $x = $i*2-1;
            $y = $j*2-1;
            if (($table[$x][$y]==$table[$x][$y+1])&&($table[$x+1][$y+1]==$table[$x+1][$y])&&($table[$x+1][$y+1]==$table[$x][$y])) {
                $up = $up.str_replace("<br><br>","","<td title='".$table[$x][$y]['description']."'  class='simp' colspan='2' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>");
            }
            else {
                $cnt = 0;
                if ($table[$x][$y]==$s) $cnt++;
                if ($table[$x][$y+1]==$s) $cnt++;
                if ($table[$x+1][$y]==$s) $cnt++;
                if ($table[$x+1][$y+1]==$s) $cnt++;
                if ($cnt==3) {
                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                    $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                    $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                }
                else {
                    if ($table[$x][$y]==$table[$x][$y+1]) { // Левые совпадают
                        $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                        if ($table[$x+1][$y]==$table[$x+1][$y+1]) {
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                        }
                        else {
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                            $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                        }
                    } else {
                        if ($table[$x+1][$y]==$table[$x+1][$y+1]) { // Правые совпадают
                            $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                            $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                        }
                        else {
                            if ($table[$x][$y]==$table[$x+1][$y]) { // Верхние совпадают
                                $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm' colspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                                if ($table[$x][$y+1]==$table[$x+1][$y+1]) {
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                }
                                else {
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                    $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                                }
                            }
                            else {
                                if ($table[$x][$y+1]==$table[$x+1][$y+1]) { // Нижние совпадают
                                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                                    $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                }
                                else {
                                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
     ...

    Рендер расписания занятий из базы данных в табличку на HTML

    Запостил: Evgesko, 28 Августа 2014

    Комментарии (2) RSS

    • Т.е. отдать это всё на обработку JavaScript'у или хотя бы шаблонизатору автор не захотел?
      Ответить

    Добавить комментарий