0

Ok, I know there's missing code from the top but it's stuf that doesnt matter and I didnt feel like modifying it with dummy data to post the full PHP page here. Anyway, the below code produces this: http://www.myu2sig.com/currentusers2.php

If you page around you will notice that it always shows 100 items per page, well, thats not the issue but this is. Theyre all nnumbered 1 to 100 but I would like them to incrementaly number by page.

So the 100 rows on page one would be 1 to 100 while the rows on page two would be numbered 201 to 300 so on and so forth. What in the below code needs to be changed to achieve what I want. Please reply i nthe following manner.

Find this...

Replace with this...

Ty !

mysql_connect('localhost',$username,$password);
   @mysql_select_db($database) or die ("Unable to select database");

	$numbers = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
	$letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');

	if (isset($_GET['n']))
	$get_numbers = (int) $_GET['n'];
	if (isset($_GET['l']))
	$get_letters = (int) $_GET['l'];
	
	$search_psn = !empty($_POST['search']) ? mysql_real_escape_string($_POST['search']) : '';

	if (isset($_GET['n']))
		$where = " WHERE psnid LIKE  '$numbers[$get_numbers]%'";
	elseif(isset($_GET['l']))
		$where = " WHERE psnid LIKE  '$letters[$get_letters]%'";
	elseif(isset($_POST['search']))
		$where = " WHERE psnid LIKE  '%$search_psn%'";
	else
		$where = " WHERE psnid != ''";

   $query="SELECT * FROM `ucard` $where ORDER BY `psnid`";

   $result=mysql_query($query);

   $num=mysql_num_rows($result);

   printf (mysql_error());
   $page = $_GET['page'];

   if (!$page) {
      $page = 1;
   }

   mysql_close();

echo '<table border="3" bordercolor="#9E853D">
	     <tr>
		   <td colspan="4"><center>Total Unique User Count: '. number_format($num) .'<br />List accurate as of '. date('n/j/Y g:ia T') .'</center></td>
		   <td colspan="2">
		   <center>';
	
	  $totalpages = (int)($num/$h);
	  if ($num % $h != 0) $totalpages++;
   
      $prevpage = max(1, $page - 1);
	  $nextpage = min($totalpages, $page + 1);
      
	  echo "Page " . $page . " of " . $totalpages . "<br />";
		   
	  $starting_user = $i = ($page - 1) * $h + 1;
	  
	  echo "Results: " . number_format($starting_user) . " to " . number_format(min($starting_user+$h-1, $num)) . "<br />";

      if ($page > 1) {
		 echo '&nbsp;<a href="./currentusers2.php?page=1" title="First Page">First</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		 echo '<a href="./currentusers2.php?page='.$prevpage.'" title="Previous Page">Previous</a>';
      }
      else {
         echo '&nbsp;First&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		 echo 'Previous';
      }

		 echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

      if ($page < $totalpages) {
         echo '<a href="./currentusers2.php?page='.$nextpage.'" title="Next Page">Next</a> ';
         echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="./currentusers2.php?page='.$totalpages.'" title="Last Page">Last</a>&nbsp;';
      }
      
      else {
		 echo 'Next';
		 echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Last&nbsp;';
      }
      
		   echo '</center></td>
		 </tr>
		 <tr>
		   <td colspan="4"><b><center><a href="currentusers2.php">Show All</a><br />';

foreach($numbers as $n => $v)
	echo '<a href="currentusers2.php?n=' . $n .'">' . $v . '</a> ';

	echo '<br />';

foreach($letters as $l => $v)
	echo '<a href="currentusers2.php?l=' . $l .'">' . $v . '</a> ';

echo '
			</center></b>
			</td>
		<td><b><center><form style="padding: 0; margin: 0;" action="currentusers2.php" method="post"><input type="text" name="search" value="Enter PSN ID" onclick=this.value=""; /><br /><input type="image" src="./usersearch.png" style="padding: 5px 0px 0px 0px;" /></form></center></b></td>
		<td><b><center>&nbsp;Placeholder !&nbsp;</center></b></td>
		</tr>
	   <tr>
        <td><b><center>#</center></b></td>
		<td><b><center>PSN ID / Profile</center></b></td>
		<td><b><center>ND Stats Page</center></b></td>
        <td><b><center>Skin (Links)</center></b></td>
        <td><b><center>Last Updated</center></b></td>
		<td><b><center>&nbsp;Placeholder !&nbsp;</center></b></td>
       </tr>';

if (mysql_num_rows($result)){

   $i = ($page - 1) * $h;
   $j = 0;
   while (($i < $num) && ($j < $h)) {
      $k = $j + $i;
	  if ($k >= $num) break;
      $psnid=mysql_result($result,$k,"psnid");
      $skin=mysql_result($result,$k,"skin");
      $lastupdate=mysql_result($result,$k,"lastupdate");

    $j++;
    
   echo '
       <tr>
        <td>' . number_format($j) . '</td>
		<td>' . '<a href="',"http://us.playstation.com/publictrophy/index.htm?onlinename=", $psnid, '" target="new_page">', $psnid, '</a>' . '</td>
		<td>' . '<a href="',"http://www.naughtydog.com/stats/index/", $psnid, '" target="new_page">', $psnid, '</a>' . '</td>
        <td>' . '<a href="',"http://www.myu2sig.com/preview/", $skin,".png", '" target="new_page">', $skin, '</a>' . '</td>
		<td>' . date('n/j/Y g:ia T', $lastupdate - 1800 ) . '</td>
		<td>&nbsp;Placeholder !&nbsp;</td>
       </tr>';
       
}

}else{

echo '<tr>
				<td colspan="6" align="center">No users found.<br />Please check your spelling & try again.</td>
			</tr>';

}
       
   echo '
       </table>';
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by MoreBloodWine
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.