{% $categoryCounter = 0; $categoriesRotatorQuery = $db->query("select * from categories where id in (select category_id from articles) order by `order` ASC"); while($categoriesRotator = $categoriesRotatorQuery -> fetchArray(SQLITE3_ASSOC)){ $categoryCounter++; %}

{{ $categoriesRotator['name'] }}

{% $categoryArticlesQuery = $db->query("select articles.id, articles.category_id, articles.slug as slug, articles.title as title, articles.excerpt as excerpt, articles.image as image, articles.created as created, authors.name as authorname, authors.linkedin as linkedin, authors.slug as authorslug, categories.name as category_name, categories.slug as category_slug from articles, authors, categories where articles.author_id = authors.id and articles.category_id = categories.id and categories.id = " . $categoriesRotator['id'] . " ORDER BY articles.created DESC limit 0,3"); while($categoryArticle = $categoryArticlesQuery -> fetchArray(SQLITE3_ASSOC)){ if($categoryCounter % 2 == 1) { %}
{{ $categoryArticle['category_name'] }}

{{ $categoryArticle['title'] }}

{{ $categoryArticle['authorname'] }} / {{ date("d F, Y", strtotime($categoryArticle['created'])) }}

{% } else { %}
{{ $categoryArticle['category_name'] }}

{{ $categoryArticle['title'] }}

{{ $categoryArticle['authorname'] }} / {{ date("d F, Y", strtotime($categoryArticle['created'])) }}

{% } %} {% } %}
{% } %}