There is a query to the database:
SELECT * FROM content INNER JOIN users ON (content.user_id = users.id) INNER JOIN categories ON (content.category_id = categories.id) After that, I get an array in PHP:
for ($i = 0; $i < mysqli_num_rows($result); $i++) { $row[] = mysqli_fetch_assoc($result); } In the template using Smarty display entries:
{foreach $row as $item} <h3><a href="content.php?id={$item.id}">{$item.title}</a></h3> <p class="date"><b>Дата добавления:</b> {$item.pubdate}</p> <p class="autor"><b>Опубликовано:</b> {$item.nickname}</p> <p class="category"><b>Теги:</b> {$item.category_name}</p> <div class="description">{$item.content}</div> <a href="content.php?id={$item.id}" class="btn btn-info">Подробнее...</a> {/foreach} The problem is that the element of the array {$item.id} is not chosen, i.e. the element corresponds to the category_id table in the category table, i.e. the last id value that I attach to the table using INNER JOIN .
How to write a query with JOIN ?