Q
Q
quicku2021-06-20 11:04:22
PHP
quicku, 2021-06-20 11:04:22

How to iterate Select(option)?

The question is in the title.
I do it this way:

<select name="category" id="category" class="form-control form-control-xl">
                                                 <? $categories = R::findAll('category');
                                                  foreach ($categories as $category){ ?>
                                                <option value="<?=$category->title_cat?>"><?=$category->title_cat?></option>
                                            <? } ?>
                                                </select>

For some reason, only 1-record is displayed, and in the database I added a different number of them.
60cef663ce6e9666285914.png
How to solve this problem, does anyone know?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pLavrenov, 2021-06-20
@pLavrenov

Obviously, no one here can tell anything because no one knows if the R::findAll('category') function works correctly. The problem is definitely in it.

S
sl0, 2021-06-20
@sl0

Forgotten before<? endforeach; ?></select>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question