Я попытался использовать 2 цикла while для одного и того же запроса.
First is for slideshow,another one is for posts.Second while executed after the endwhile. But when I delete first while then I was able to get posts otherwise only 1st while is working
Что я уже пробовал:
<pre><?php include "libs/db.php"; include "libs/config.php"; include "libs/function.php"; $db = new database(); $query = "SELECT * from posts order by id DESC"; $posts = $db->select($query); $query = "SELECT * from categories"; $cats = $db->select($query); ?>
<!--Сначала пока ... >
<?php while($row1 = $posts->fetch_array()) :?> <div class="welcome-single-slide"> <!-- Post Thumb --> <img src="images/<?php echo $row1['image'];?>" alt=""> <div class="project_title"> <div class="post-date-commnents d-flex"> <a href="#">May 19, 2017</a> <a href="#">5 Comment</a> </div> <a href="single.php?idd=<?php echo $row1['id'];?>"> <h5>“<?php echo $row1['title'];?>"</h5> </a> </div> <!-- Overlay Text --> </div> <?php endwhile;?> </section> <!-- ****** Welcome Area End ****** --> <!-- ****** Categories Area Start ****** --> <section class="categories_area clearfix" id="about"> <div class="container"> <div class="row">
<?php while ($row = $posts->fetch_array()) :?> <!-- Single Post --> <div class="col-12"> <div class="list-blog single-post d-sm-flex wow fadeInUpBig" data-wow-delay=".8s"> <!-- Post Thumb --> <div class="post-thumb"> <img src="images/<?php echo $row['image'];?>" alt=""> </div> <!-- Post Content --> <div class="post-content"> <div class="post-meta d-flex"> <div class="post-author-date-area d-flex"> <!-- Post Author --> <div class="post-author"> <a href="#"><?php echo $row['author'];?></a> </div> <!-- Post Date --> <div class="post-date"> <a href="#"><?php echo $row ['date'];?></a> </div> </div> <!-- Post Comment & Share Area --> <div class="post-comment-share-area d-flex"> <!-- Post Favourite --> <div class="post-favourite"> <a href="#"> 10</a> </div> <!-- Post Comments --> <div class="post-comments"> <a href="#"> 12</a> </div> <!-- Post Share --> <div class="post-share"> <a href="#"></a> </div> </div> </div> <a href="#"> <h4 class="post-headline"><?php echo $row ['title'];?></h4> </a> <p><?php echo substr($row ['content'],0,300);?></p> <a id="continuereading" href="single.php?idd=<?php echo $row ['id'];?>" class="read-more">Continue Reading..</a> </div> </div> </div> <!--This is the second while for the same query--> <?php endwhile ;?>