Re: I was asking about PHP Paging Concept that how to do that sorry for confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you're referring to using PHP to displays sets of MySQL data as  
pages, that's a whole lot to get across in e-mail, but Google is your  
friend:
http://www.google.com/search?q=php 
+paging&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en- 
US:official&client=firefox-a

Generally, you'll be using $_GET['somevar'], where 'somevar' is the  
page you're on. You go on from there to figure out what the next and  
previous page are.

So here would be an example (I'm not dropping in error checking, and  
this is just a quick example, so there's always the possibility I  
have an error in the code).:

<html>
<?php
$current_page = $_GET['somevar'];
$max_page = 10; // could be a high page number you set from a mysql  
query, or it could be some number your pick
if (!isnumeric($current_page)) {
     $current_page = 1;
} elseif ($current_page > $max_page) {
     $current_page = $max_page;
} elseif ($current_page < 1) {
     $current_page = 1;
}
$next_page = $current_page + 1;
$previous_page = $current_page - 1;
?>
...
<a href="this_doc.php?somevar=<?php echo $previous_page; ?>">Prev  
Page</a> ||  <a href="this_doc.php?somevar=<?php echo $next_page; ? 
 >">Next Page</a>
<?php
     // display stuff for $current_page
?>
...
</html>


A little note on the code above -- I have a personal preference for  
using 1 as the lowest/start page, and then offset it to 0 if I need  
to. Some people prefer to use 0 instead because it corresponds with  
the first result set in a database query.

You can also use variants of the code above to turn off the linking  
for the last and first pages when you get to them.

If this is your first foray into paging, let us know if you have any  
questions on structure or why what does what. I'm sure what you  
actually want is something MySQL-related, so when you get to a point  
that you need specific help there, hit the group up.
--
Joe

On Sep 25, 2008, at 2:10 PM, embroidtiger2008 wrote:

> I was asking about PHP Paging Concept that how to do that sorry for
> confusion.
>
> Still waiting for ur replies.
>
> Moin.
>
>
> 



[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux