T
T
The Dragger2015-04-30 09:33:58
MySQL
The Dragger, 2015-04-30 09:33:58

Is it right to store whole huge html codes in the database?

Hello everyone at work, I saw a bunch of html code in one table cell. Is this correct, I heard no.

<div class="accordion" id="accordion2">
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#бектемир">
        Бектемирский район
      </a>
    </div>
    <div id="бектемир" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#мирзо">
        Мирзо-Улугбекский район
      </a>
    </div>
    <div id="мирзо" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 2 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#мирабад">
        Мирабадский район
      </a>
    </div>
    <div id="мирабад" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#алмазар">
        Алмазарский район
      </a>
    </div>
    <div id="алмазар" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#сергели">
        Сергелиский  район
      </a>
    </div>
    <div id="сергели" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#учтепинский">
        Учтепинский район
      </a>
    </div>
    <div id="учтепинский" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#чиланзар">
        Чиланзарский район
      </a>
    </div>
    <div id="чиланзар" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#шайхонтохурский">
        Шайхонтохурский район
      </a>
    </div>
    <div id="шайхонтохурский" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#юнусабадский">
        Юнусабадский район
      </a>
    </div>
    <div id="юнусабадский" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#яккасарайский">
        Яккасарайский район
      </a>
    </div>
    <div id="яккасарайский" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
 <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#яшнободский">
        Яшнободский район
      </a>
    </div>
    <div id="яшнободский" class="accordion-body collapse in">
      <div class="accordion-inner">
        Shu 1 rayonga tegishli tablitsa
      </div>
    </div>
  </div>
</div>

all this code was in one table cell

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Khomenko, 2015-04-30
@IPD2

It depends on the task. If the task is to:
- Implement a site section for storing display blocks that the administrator can quickly edit in the visual editor, create and connect to displays through a special component in the system. Plus caching, language versions, etc.
For this task, it's fine.

F
FanatPHP, 2015-04-30
@FanatPHP

It is this kind of code that is wrong to store, for obvious reasons.
In general, if this is, say, an article with markup - why not?

M
Maxim, 2015-04-30
@go3l337

Complex structures where ids are needed, classes (like the one you presented) should be stored in an html / xml file and included in the content by some kind of component (as is done in Bitrix, for example).
It is worth storing html markup in the database if these are the simplest structures like those that are obtained when working in a visual editor (markdown, ckeditor), as is done in many cms (drupal, the same Bitrix, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question