V
V
viktorross2019-10-15 12:23:13
css
viktorross, 2019-10-15 12:23:13

How to output a loop in smarty?

hello, please tell me an example of outputting a loop in smart along with a php request to the database.
I searched the Internet almost everything does not work and an error occurs.
I just need a query to a row in the database, for example, the ads table and the name column for this column, there are several thousand records, I want to display all of them in one array in the template in a loop, no matter how much I tried, nothing happens, maybe someone saw a 100% working example or knows

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Andrej Sharapov, 2018-07-23
@adik_zhuman

Like this? https://jsfiddle.net/madeas/cgga14pr/

O
Oleg, 2018-07-23
@politon

https://vestride.github.io/Shuffle/

V
Vadim Kot, 2018-07-23
@vadimkot

https://github.com/topics/filter

T
tyzberd, 2018-07-23
@tyzberd

https://isotope.metafizzy.co/v2/

L
lubezniy, 2019-10-15
@lubezniy

Smarty does not provide database queries; it's basically none of his business. He needs to serve a ready-made array and iterate over it in a loop - for example, foreach.

B
BATPYIIIKOB, 2019-10-15
@BATPYIIIKOB

<?php
$arr = array(1000, 1001, 1002);
$smarty->assign('myArray', $arr);
?>

<ul>
{foreach from=$myArray item=foo}
    <li>{$foo}</li>
{/foreach}
</ul>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question