R
R
Roman Nazaruk2017-06-05 14:38:13
Vue.js
Roman Nazaruk, 2017-06-05 14:38:13

Searching data from db using YII2 form?

Hello, I have my own form with checkboxes and inputs. I want that after selecting the necessary parameters, when I click the "Show" button, I would display the necessary records from the database.

The form
<fieldset class="search-column">
        <legend>Тип жилья:</legend>
        <ul class="type-checkbox">
          <li>
            <input type="checkbox" name="hotel" id="hotel-field" checked>
            <label for="hotel-field">Гостиница</label>
          </li>
          <li>
            <input type="checkbox" name="motel" id="motel-field" checked>
            <label for="motel-field">Мотель</label>
          </li>
          <li>
            <input type="checkbox" name="apart" id="apart-field" checked>
            <label for="apart-field">Аппартаменты</label>
          </li>
        </ul>
      </fieldset>
      <div class="search-column-range">
        <div class="range-title">Стоимость в сутки(Р):</div>
        <div class="price-filter">
          <div class="min-price">
            <input type="text" name="start-price" id="start-price-field">
            <label for="start-price-field">от 0</label>
          </div>
          <div class="max-price">
            <input type="text" name="final-price" id="final-price-field">
            <label for="final-price-field">до 3000</label>
          </div>
        </div>
        <button class="show-hotels" type="submit">Показать</button>
      </div>
    </form>


I have so far made the usual output of all data from the desired database table with pagination.
Conclusion
<?php foreach ($articles as $article):?>
      
        
          <img src="" alt="">
        
          <a href="#"><?= $article->hotelname?></a>
          <?= $article->type?>
          От <?= $article->min_price?> Р.
          <a href="#">Подробнее</a>
          <a href="#">Забронировать</a>
        
      
      <?php endforeach; ?>

        <?php
          echo LinkPager::widget([
              'pagination' => $pagination,
          ]);
        ?>


I'm really bad at Yii2 and programming, so I don't really understand how using Yii2 you can connect checkboxes and inputs to the database and output data when needed.
Please help with code

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-10-01
@vikholodov

Or maybe, instead of doing this nonsense, just set a placeholder?

<v-text-field
  placeholder="-"
  v-model="product.product.comment"
  :solo="none_change"
  :readonly="none_change"
></v-text-field>

M
Maxim Fedorov, 2017-06-05
@qonand

I'm really bad at Yii2 and programming, so I don't really understand how using Yii2 you can connect checkboxes and inputs to the database and output data when needed.

Then maybe it's worth pumping up your programming skills, reading the Yii documentation, and not asking to write the code for you?
Question: here's an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question