Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:51+00:00 2026-06-04T16:08:51+00:00

I have a php/mysql list, where I can display lots of thumbnails. My problem

  • 0

I have a php/mysql list, where I can display lots of thumbnails.

My problem is that there are too many images to display in one page. I would like to divide it so that I can get some page links or something at the bottom?

Like: 1,2,3,4,5,6,7,8 or next and prev…

Here is the current code:

<?php
    if ($db_found) {
        $SQL = "SELECT * FROM myTable";
        $result = mysql_query($SQL);

        while ($db_field = mysql_fetch_assoc($result)) {
            echo '<li>';
            echo '<div class="thumb"><img src="images/thumbnails/'.$db_field['image'].'" alt="" /></a></div>';
            echo '</li>';
        }
        mysql_close($db_handle);
    }
?>

How can I add some page links here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:08:52+00:00Added an answer on June 4, 2026 at 4:08 pm

    it’s much more easy with Jquery but i Recommends you to work with PHP for start,
    It can only develop your head than to add some JQuery code will get you everything.
    anyway simple paging with PHP goes like that,
    the key’s for learning this code is to understand:
    intval,LIMIT,mysql_num_rows,mysql_fetch_assoc,mysql_fetch_row,ceil,COUNT
    after you will learn each off them the code will be much easy to understand and you can develop it and add some of your own Improvements.
    The Credit for this Excellent site : PHPGuide

     $per_page = 5; 
     $page = 1;
    
     if (isset($_GET['page'])) 
     {
      $page = intval($_GET['page']); 
      if($page < 1) $page = 1;
    }
    
    
     $start_from = ($page - 1) * $per_page; 
    
     mysql_connect(..);
     mysql_select_db(..);
    
     $current_items = mysql_query( "SELECT * FROM `test` LIMIT $start_from, $per_page");
     if( mysql_num_rows($current_items) > 0)
     {
      while($item = mysql_fetch_assoc($current_items))
      {
        echo $item['text'], '<br/>';
      }
     }
     else
     {
      echo 'this page does not exists'; 
     }
    
    
     $total_rows = mysql_query("SELECT COUNT(*) FROM `test`");
     $total_rows = mysql_fetch_row($total_rows);
     $total_rows = $total_rows[0];
    
     $total_pages = $total_rows / $per_page;
     $total_pages = ceil($total_pages); # 19/5 = 3.8 ~=~ 4
    
     for($i = 1; $i  <= $total_pages; ++$i)
     {
      echo "<a href='?page=$i'>$i</a> &nbsp;&nbsp;";
     }
    

    The Code is Very Easy to understand and very simple.
    and about the prev and forward page it’s one of the improvements you will do after you get this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of dates stored in MySQL using PHP. These were stored
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ,
I have a php/mysql poll that I'm trying to modify. It sets a unique
I have a PHP/MySQL query that returns to an HTML table, and I'm stuck
I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code
I have a php page that pulls data from a mysql database based on
We have an PHP/MySQL application where the users can create their own databases, which
I have a Reward System based on MySQL/PHP. Teachers award students points; students can
I have this piece of php - mysql code: When a user tagged in
I have PHP code which connects to MySql and encodes data to JSON. Later

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.