The following non-trivial PHP code is available:
$req = DB::run("SELECT * FROM `license` WHERE `id_user`='" . $this->user['id'] . "' ORDER BY `id` DESC LIMIT " . $this->page . ", " . $this->message); while ($row = $req->fetch(PDO::FETCH_ASSOC)) { $arrayrow[] = $row; $reqs = DB::run("SELECT * FROM `cms_php` WHERE `cms`='" . $row['cms'] . "' ORDER BY `id` ASC"); while ($rows = $reqs->fetch(PDO::FETCH_ASSOC)) { $arrayrows[] = $rows; } } I pass it to the template like this:
SmartySingleton::instance()->assign(array( 'arrayrow' => $arrayrow, 'arrayrows' => $arrayrows )); In the template output like this:
{foreach $arrayrow as $row} <tr> <td>{$row.namecms|esc}</td> <td>{$row.code}</td> <td>{if $row.activation == 1}активирована{else}не активирована{/if}</td> <td> {if $row.price == 0} {foreach $arrayrows as $rows} {if $row.cms == $rows.cms} <span><a href="{$home}/load/{$row.cms}/{$rows.id}">{$rows.name|esc}</a></span> {/if} {/foreach} {else} {foreach $arrayrows as $rows} {if $row.cms == $rows.cms} <span><a href="{$home}/profile/load/{$row.id}/{$rows.id}">{$rows.name|esc}</a></span> {/if} {/foreach} {/if} </td> </tr> {/foreach} What is wrong: i.e. values are repeated?
How to display in the template?

Имеется следующий не тривиальный PHP код- just the very quite trivial and, in principle, wrong ...... because most likely it is enough to group them by a certain sign ... or to join ... i.e. Only one query ............ and what is the expected output? - Alexey Shimansky$req = DB::run("SELECT * FROM license WHERE id_user=? ORDER BY id DESC LIMIT ?, ?", [$this->user['id'],$this->page, $this->message]);- Ipatiev