Jump to content

Conf1

New Members
  • Posts

    2
  • Joined

  • Last visited

Conf1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So this is my code for pagination <?php $num_rec_per_page=8; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * $num_rec_per_page; $sql="SELECT * FROM `images` ORDER BY `id` DESC LIMIT $start_from,$num_rec_per_page"; $rdata=mysqli_query($mysqli, $sql); while($res=mysqli_fetch_array($rdata)) { $imgname=$res['image']; $path = 'folder/'.$imgname; echo " <div class='col-xs-6 col-md-3'> <a href='#'' class='thumbnail'> <img src='$path' height='500' width='500'> </a> </div>"; } $total_records = mysqli_num_rows($rdata); //count number of records $total_pages = ceil($total_records / $num_rec_per_page); for ($i=1; $i<=$total_pages; $i++) { }; ?> <br><br> <footer> <br><br> <div class="well text-center"> a href="<?php echo "index.php?page=1"; ?>"><button type="button" class="btn btn-fresh text-uppercase">Previous page</button></a> <a href="<?php echo "index.php?page=".$i." "; ?>"><button type="button" class="btn btn-sky text-uppercase">Next page</button></a> </div> Now when I press "Next page" button, I can go to only 2 page, not more, but there must be more pages because there is more posts..
  2. Im creating simple blog I created admin login, page for inserting new post and other.. Now, I have in database: id title short-text long-text And now, i want to display on index.php (homepage) only Title and short-text, then on press button to go on post page and show only title and long-text But all posts to show by IDs I have tried, but I failed, i dont know how to do it.. Just give me some ways to do it
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.