Jump to content

Recommended Posts

So i have this page that pretty much displays all the members in the database, and its split into pages using a pagination php script.

 

The problem is that i want the ID number displayed next to it, however the database record id jumps since some records have been deleted. So while there were a total of 1000 records 10 have been removed so instead of showing the accurate ID number of 995 on the last record it displays the number 1000 ....

 

I've tried just assigning a number to each record using the following code...

$get_members = "SELECT * FROM members ORDER BY ID ASC LIMIT $rowsperpage OFFSET $offset";
$run_mem_query = mysql_query($get_members) or die(mysql_error());
$club_id = 1;
while($member = mysql_fetch_assoc($run_mem_query)){
?>

<li><strong><?php echo $club_id++ ;?>.</strong><?php echo $member['username'] ;?> - <span><?php echo $member['state'] ;?></span></li>

<?php
}

 

 

The problem with that is that every time i click to go to the next page the number  sequence refreshed back to 1 and starts over....

 

i've been trying to find a way around his, but can't....does anyone have any solutions to this???

 

Here's the script that controls the pagination

 

<?php
								if ($totalpages > 1){
									/*********** Start the pagination links ********/
									echo "<p>";
									// range of num links to show
									$range = 6;
									// if not on page 1, don't show back links
									if ($currentpage > 1) {
									   // show << link to go back to page 1
									   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First</a> ";
									   // get previous page num
									   $prevpage = $currentpage - 1;
									   // show < link to go back to 1 page
									   echo " 
										<a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>Previous</a> ";
									} // end if 
									if($result > 0){
									// loop to show links to range of pages around current page
										for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
										   // if it's a valid page number...
										   if (($x > 0) && ($x <= $totalpages)) {
											  // if we're on current page...
											  if ($x == $currentpage) {
												 // 'highlight' it but don't make a link
												 echo " <b>$x</b> ";
											  // if not current page...
											  } else {
												 // make it a link
												 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
											  } // end else
										   } // end if 
										} // end for
									}else{
										echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>1</a>";
									}
									// if not on last page, show forward and last page links        
									if ($currentpage != $totalpages) {
									   // get next page
									   $nextpage = $currentpage + 1;
										// echo forward link for next page 
									   echo " 
										<a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>
											Next
										</a> ";
									   // echo forward link for lastpage
									   echo " 
									   <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'> Last </a> ";
									} // end if
									echo "</p>\n";
									/****** end build pagination links ******/

								}
							?>

 

okay maybe i should make this more clear..

 

I want to be able to display the records the following way...

 

1.record name

2. record name

3.record name

4. record name

5. record name

 

and then when the user clicks on next page the records start where the last left off..in this case its number 5 so the first record on the next page will be 6. and so on

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.