Hi Everyone!
My question is on Pagination (as it is called). I have a php program that accesses a database and shows the result list with HTML. Well, if my result list is quite long how do i code so that only say 10 rows show per page.

I know that there have been past discussions on Pagination. I went through them. But as i am a novice, i could not really understand the logic of the long codes. So if someone could take little time out and give me an overview of the basic logic of pagination and how it works...would be greaaat Help!!

Here is my php file

/* PHP Program to List all books with title 'HTML Guide'
//Connecting to database using PDO
$dsn='mysql:host=localhost; dbname=test';
$db= new PDO ($dsn, $username, $password);
//Select data from Database
$query= 'SELECT * FROM  book_list WHERE BookTitle="HTML Guide"';
$results=$db->query($query); //PDOStatement Object
<html> <!--Rendering the SELECT query through HTML and PHP-->
        <title>My Book List</title>
        <link rel="stylesheet" type="text/css" href="./FormatStyle.css">
                <!--TABLE HEADER-->
                <th>Serial No.</th><th>Book Title</th><th>Price</th>
            <!--Php loop to list out all rows from SELECT query-->
            <?php foreach ($results as $result) { ?>
                <td><?php echo$result['Author']; ?></td>
                <td><?php echo$result['BookTitle']; ?></td>
                <td><?php echo$result['Price']; ?></td>
            <?php } ?>           <!--foreach loop PHP  ends-->
        </table>                 <!--End of table body-->
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.