Current location: Hot Scripts Forums » Programming Languages » PHP » Page numbers...


Page numbers...

Reply
  #1 (permalink)  
Old 07-05-04, 08:08 PM
dannyallen dannyallen is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Page numbers...

I have a script that shows page numbers, but I want it to only show four numbers at a time, just like vbulletin does, but instead of just showing 3 numbers, I want it to show four at a time. Right now, it just shows all of the pages. I want it to be like "2 3 4 5" if there are 5 pages and you are on the last page. I want it to be like "1 2 3 4" if there are 5 pages and you are on the first page. Here is my current code:
Code:
$display_number = 10;

if (!isset($num_pages)) {

	$query_result1 = mysql_query ("SELECT * FROM topics WHERE forumid = '$fid'") or die (mysql_error());

	$num_results = @mysql_num_rows ($query_result1);
	if ($num_results > $display_number) {
		$num_pages = ceil ($num_results/$display_number);
	} elseif ($num_results > 0) {
		$num_pages = 1;
	}
	$start = 0; 
}

if ($num_pages > 1) {
		
	if ($start == 0) {
		$current_page = 1;
	} else {
		$current_page = ($start/$display_number) + 1;
	}
	echo " | ";

	if ($start != 0) {
		$start1 = $start - $display_number;
		echo "<a href=forum.php?fid=$fid&start=$start1&num_pages=$num_pages>Previous</a> ";
	}


	for ($i = 1; $i <= $num_pages; $i++) {
		$next_start = $start + $display_number;
			if ($i != $current_page) {
			$start11 = $display_number * ($i - 1);
			echo "<a href=forum.php?fid=$fid&start=$start11&num_pages=$num_pages>$i</a> ";
		} else {
			echo "<span class=belowlogo><b>$i</b></span> ";
		}
	}
	
	if ($current_page != $num_pages) {
		$start111 = $start + $display_number;
		echo "<a href=forum.php?fid=$fid&start=$start111&num_pages=$num_pages>Next</a>";
	}
	
}
Can you do it with that code? If not, can you help me with some other code?
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
Please Help! Display Records page by page peter_toronto PHP 5 02-20-08 09:12 AM
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Paginating problem,extra empty page morrowind PHP 2 05-03-04 03:32 AM
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:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.