Current location: Hot Scripts Forums » Programming Languages » PHP » Need to add page numbers at top... Please Assist.


Need to add page numbers at top... Please Assist.

Reply
  #1 (permalink)  
Old 11-29-04, 12:50 PM
Soulidified Soulidified is offline
Newbie Coder
 
Join Date: Jul 2003
Location: West Side
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Need to add page numbers at top... Please Assist.

This Code works great for grabbing my article splitting it up and adding page numbers at the bottom. Now what I would like to do is. have page numbers on top. for example, on page 2, have it say page 2 of 2 (or how many pages total) on the top of the page... Here is the code, I have done endless research and am just stuck!

Code:
<html>
<body>


<?


$result = mysql_query("
SELECT * FROM $table 
ORDER BY article_id DESC 
LIMIT 1");

$articleRow = mysql_fetch_array($result);
$articleText = $articleRow['article'];
?>

<?

if(isset($_GET['page'])) { 
    $pageNumber = $_GET['page']; 
} else { 
    $pageNumber = 1; 
    } 


$theString = $articleText;
// this is where you would put in your article, I used a string 

$charactersPerPage = 2000; 
// this is where you would put the characters you want on the page 

$totalPages = ceil(strlen($theString)/$charactersPerPage); 
// this gets how many pages you'll need (the ceil() function rounds up) 

$startNumber = ($pageNumber-1)*$charactersPerPage; 
// because PHP is a zero-based indexing language, we must subtract one (but that makes it easier I think...) 

$thisPageChars = substr($theString,$startNumber,$charactersPerPage)  ; 
// select the portion of the content you want to show using substring 
// the start number is the index of the string you'll start at, 
//     and we tell it to include as much as is allowed per page 
$endNumber = $startNumber+strlen($thisPageChars)-1; 

echo $thisPageChars; 

?> 
<br /><br /> 
<?php 
// The next part prints the page numbers, I know it looks weird because of a few beauty things I did... 
// however, the only important part is the $i==$pageNumber conditional section 
for($i=1;$i<=$totalPages;$i++) { 
     
    if($i==1) { 
        echo "| "; 
    } else { 
        echo " "; 
    } 
     
    if($i==$pageNumber) { 
        echo "<strong>" . $i . "</strong>"; 
    } else { 
        echo "<a href=\"?page=" . $i . "\">" . $i . "</a>"; 
    } 
     
    echo " |"; 
} 
?> 

</body>
</html>
__________________
"Go Bigger"
Reply With Quote
  #2 (permalink)  
Old 11-29-04, 12:53 PM
Soulidified Soulidified is offline
Newbie Coder
 
Join Date: Jul 2003
Location: West Side
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
here is a link...

So you guys can see what the code I am using does... It is pretty cool. I just need help on getting page numbers (1 of 10 etc) on top of the page... Thanks for alot!

click me
__________________
"Go Bigger"
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Page numbers... dannyallen PHP 0 07-05-04 08:08 PM
Help need to add thumbnail page Pabstman Script Requests 1 06-29-04 03:37 PM
page browsing problem mivec PHP 3 04-17-04 03:43 AM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM


All times are GMT -5. The time now is 05:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.