] 1 I have categorie.php in which articles from the selected category are stored, in each block with an article there is a block in which the number of comments to the article should be displayed. The questionshow.php displays an article. I have a question how to do so in order to count the number of comments on the questionshow.php page and display the result of the calculation in the block on the categorie.php page? Write if something is not enough for you to understand my question, throw off everything you need.
<?php $article = mysqli_query($connection, "SELECT * FROM `articles` WHERE `categorie_id` = " . (int) $_GET['id'] ); if( mysqli_num_rows($article) <= 0 ) { ?> <div id="content"> <div class="container"> <div class="row"> <section class="content__left col-md-8"> <div class="block"> <h3>Ошибка!</h3> <div class="block__content"> <div class="full-text"> Запрашиваемая Вами Страница Не Существует! </div> </div> </div> </section> <section class="content__right col-md-4"> <div class="block"> <h3></h3> <div class="block__content"> </div> </div> </section> </div> </div> </div> <?php } else $art = mysqli_fetch_assoc($article); ?> <?php $categories = mysqli_query($connection, "SELECT * FROM `articles_categories`"); while( $cat = mysqli_fetch_assoc($categories) ) ?> <?php $art_cat = false; foreach( $categories as $cat ) { if( $cat['id'] == $art['categorie_id']) { $art_cat = $cat; break; } } ?> <div class="w-100 mt-4"> <div class="block block-shadow p-1"> <div class="block block-shadow light-input-bg py-1"> <h3 class="light-text m-0 d-inline-block"><?php echo $art_cat['title']; ?></h3> <p class="light-text d-inline-block m-0 mt-1 float-right"><?php echo 'Вопросов: ' . mysqli_num_rows($article);?></p> </div> <div class="p-2"> <div class="card example-2 square scrollbar-dusty-grass-2 square thin bg-transparent"> <?php echo'<a href=/questionshow.php?id='. $art['id']. '><div class="question-block block-shadow mt-1 mb-0"> <div><h3>'. mb_substr(strip_tags($art['title']) , 0, 75, 'utf-8'). '</h3></div> <div class="question-block-right"> <div class="question-block-right-in text-white"> <span class="time-question">'.$art['pubdate'].'</span> </div> <p>Ответов <span>'.mysqli_num_rows($article).'</span></p> </div> </div> </a>'; ?> Комментарии хранятся в questionshow.php.Вот код комментариев: <?php $comments = mysqli_query($connection, "SELECT * FROM `comments` WHERE `id_articles` = " . (int) $art['id'] . " ORDER BY `id` DESC "); ?> <h5 class="mt-2 light-text mb-0">Комментарии</h5> <?php { while( $comment = mysqli_fetch_assoc($comments) ) { echo'<div style="padding-bottom: 1px !important;" class="block block-shadow light-bg p-0"> <div class="block block-shadow light-bg m-0 py-1"> <h3 class="light-text m-0 d-inline-block"> <img class="d-inline-block" style="border-radius: 90px;" width="35" src=/images/avatars/200x200.png alt=""> <p style="font-size: 20px" class="d-inline-block m-0">'.$comment ['author'].'</p> </h3> <p style="padding: 10px 0px;" class="light-text d-inline-block m-0 mt-0 float-right">'.$comment ['pubdate'].'</p> </div> <div class="block block-shadow dark-bg m-1 light-text"> <p class="mb-0">' .$comment['text']. '</p> </div> </div>'; } ?> <?php } ?> 