Advertisement
Guest User

Untitled

a guest
Dec 30th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2. $news = mysqli_query($connection, "SELECT * FROM `articles_categories` WHERE `id`");
  3. while ( $new = mysqli_fetch_assoc($news) )
  4. {
  5. ?>
  6.  
  7.  
  8.  
  9. <div class="block">
  10. <a href="/articles.php?categorie=<?php echo $new['id']; ?>">Все записи</a>
  11. <h3><?php echo $new['title']; ?> [Новейшее]</h3>
  12. <div class="block__content">
  13. <div class="articles articles__horizontal">
  14.  
  15. <?php
  16. $articles = mysqli_query($connection, "SELECT * FROM `articles` WHERE `categorie_id` = 1 ORDER BY `id` DESC LIMIT 4");
  17.  
  18. while($art = mysqli_fetch_assoc($articles))
  19. {
  20.  
  21. ?>
  22. <article class="article">
  23. <div class="article__image" style="background-image: url(/static/images/<?php echo $art['image']; ?>);"></div>
  24. <div class="article__info">
  25. <a href="/article.php?id=<?php echo $art['id']; ?>"><?php echo $art['title']; ?></a>
  26. <div class="article__info__meta">
  27. <?php
  28. $art_cat = false;
  29. foreach( $categories as $cat )
  30. {
  31. if ( $cat['id'] == $art['categorie_id'] )
  32. {
  33. $art_cat = $cat;
  34. break;
  35. }
  36. }
  37. ?>
  38. <small>Категория: <a href="/articles.php?categorie=<?php echo $art_cat['id']; ?>"><?php echo $art_cat['title']; ?></a></small>
  39. </div>
  40. <div class="article__info__preview"><?php echo mb_substr(strip_tags($art['text']), 0, 80, 'utf-8'); echo ' ...'; ?></div>
  41. </div>
  42. </article>
  43. <?php
  44. }
  45. ?>
  46.  
  47. </div>
  48. </div>
  49. </div>
  50.  
  51. <?php
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement