Reply
Pagination number links help!
Old 11-02-2009, 07:02 PM Pagination number links help!
Super Talker

Posts: 109
Name: Not Telling
Trades: 0
PHP Code:
<?php
error_reporting
(E_ALL);
ini_set('display_errors''1');
include(
"inc/config.php");

$pagenum = (isset($_GET['pagenum'])) ? (int) $_GET['pagenum'] : 1;

$data mysql_query("SELECT * FROM accounts") or die(mysql_error());
$rows mysql_num_rows($data);
$page_rows 4;
$last ceil($rows/$page_rows);
if (
$pagenum 1)
{
$pagenum 1;
}
elseif (
$pagenum $last)
{
$pagenum $last;
}
$max 'limit ' .($pagenum 1) * $page_rows .',' .$page_rows;
$data_p mysql_query("SELECT * FROM accounts $max") or die(mysql_error());
while(
$info mysql_fetch_array$data_p ))
{
echo 
"Username: ";
Print 
$info['username'];
echo 
"<br>";
echo 
"Password: ";
Print 
$info['password'];
echo 
"<br>----";
echo 
"<br>";
}
echo 
"<p>";
echo 
" --Page $pagenum of $last-- <p>";
if (
$pagenum == 1)
{
}
else
{
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo 
" ";
$previous $pagenum-1;
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}
echo 
" ---- ";
if (
$pagenum == $last)
{
}
else {
$next $pagenum+1;
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo 
" ";
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}
?>
----

Now I need help with another thing, How would I do it so instead of it posting it like this when im at the first page:

---- Next -> Last ->>

To like this:

| 1 | 2 | 3 | Last ->>

Like it adds a number based on how many pages, its like instead of using the Next -> thing clicking over and over again to get to like page 5.

Same thing with the rest of the pages:

<<-First | 1 | 2 | 3 | Last ->>

And the last page:

<<-First | 1 | 2 | 3 |

Does anyone know how to do this? I want number pages instead of clicking to get to the next page or the page before.
__________________
MY MSN: Sith717@Hotmail.com
PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.

Last edited by sith717; 11-02-2009 at 07:23 PM..
sith717 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-02-2009, 07:24 PM Re: Pagination number links help!
Super Talker

Posts: 109
Name: Not Telling
Trades: 0
I have done it:

PHP Code:
<?php
error_reporting
(E_ALL);
ini_set('display_errors''1');
include(
"inc/config.php");

$pagenum = (isset($_GET['pagenum'])) ? (int) $_GET['pagenum'] : 1;

$data mysql_query("SELECT * FROM accounts") or die(mysql_error());
$rows mysql_num_rows($data);
$page_rows 2;
$last ceil($rows/$page_rows);
if (
$pagenum 1)
{
$pagenum 1;
}
elseif (
$pagenum $last)
{
$pagenum $last;
}
$max 'limit ' .($pagenum 1) * $page_rows .',' .$page_rows;
$data_p mysql_query("SELECT * FROM accounts $max") or die(mysql_error());
while(
$info mysql_fetch_array$data_p ))
{
echo 
"First Name: ";
Print 
$info['username'];
echo 
"<br>";
echo 
"Last Name: ";
Print 
$info['password'];
echo 
"<br>----";
echo 
"<br>";
}
echo 
"<hr>";
if (
$pagenum == 1)
{
}
else
{
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=1'>First</a> ";
echo 
" |";
echo 
" ";
$previous $pagenum-1;
$current $pagenum;
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'>$previous</a> ";
echo 
" | ";
}
echo 
"$pagenum";
if (
$pagenum == $last)
{
}
else {
$next $pagenum+1;
echo 
" | ";
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'> $next</a> ";
echo 
" ";
echo 
"| ";
echo 
" <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last</a> ";
}
?>
__________________
MY MSN: Sith717@Hotmail.com
PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.
sith717 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Pagination number links help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11950 seconds with 13 queries