Incorporating Pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
taz321
Forum Newbie
Posts: 1
Joined: Sat Feb 09, 2008 12:51 pm

Incorporating Pagination

Post by taz321 »

Hi

Im starting to do pagination with my work, basically i am developing a helpdesk system where users would submit requests for any technical issues.

I have a list of 60 requests but want to narrow this down so that only one page shows 10 results and the next page shows the next ten.

i.e Prev 1 2 3 4 5 Next

Iv started to have a go, but no success, any help would be appreciated

Code: Select all

<?php
 
    $query1 = mysql_query("SELECT * FROM form LIMIT $startrow, 10")or die (mysql_error());
    
    if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
    $startrow = 0;
 
    } else {
    $startrow = (int)$_GET['startrow'];
    
    }
 
?>
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Incorporating Pagination

Post by Mordred »

You're on the right track, just missing some basic concepts about how var substitution works in strings. Move the query line AFTER you init $startrow.

Also, don't use is_numeric, use ctype_digit instead.
Post Reply