Jump to content

Pagination should work right?


Zoofu

Recommended Posts

<?php

$id = mss($_GET['id']);
$page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; 
$page = ceil($page);

$limit = 15; 
$start = $limit; 
$end = $page*$limit-($limit); 

if($id){
$sql = "SELECT * FROM `users` WHERE `id`='".$id."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
	echo "Invalid Path!";
}else {
	$row = mysql_fetch_assoc($res);
	$sql2 = "SELECT * FROM `users` WHERE `id`='".$row['id']."'";
	$res2 = mysql_query($sql2) or die(mysql_error());
	$row2 = mysql_fetch_assoc($res2);
	if($row2['admin'] == 1 && $admin_user_level == 0){
		echo "You do not have permission!";
	}else {
		$amount_check = "SELECT * FROM `users` WHERE `id`='".$id."'"; 
		$amount_check_res = mysql_query($amount_check) or die(mysql_error()); 
		$amount_count = mysql_num_rows($amount_check_res); 
		$pages = ceil($amount_count/$limit); 

		$previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=browse&page=".($page-1)."\">« Prev</a>"; 
		$nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=browse&page=".($page+1)."\">Next »</a>"; 
		echo "<tr><td align=\"right\" colspan=\"2\">\n";
		echo "Pages: ";
		echo $previous; 
		for($i=1;$i<=$pages;$i++){ 
		    $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=browse&page=".$i."\">".$i."</a> "; 
     
		    echo $href; 
		} 
		echo $nextpage; 
		echo "</td></tr>\n";
		$select_sql = "SELECT * FROM `users` WHERE `id`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; 
		$select_res = mysql_query($select_sql) or die(mysql_error()); 

		while($rowr = mysql_fetch_assoc($select_res)){
			echo "<tr><td class =\"forum_header\">".$rowr['username']."</td></tr>\n";
		}
	}
}
}else{
echo "Invalid Path!";
}

?>

 

It just keeps returning Invalid Path! :/

Link to comment
Share on other sites

i'm not sure, but try this:

<?php

$id = mss($_GET['id']);
$page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; 
$page = ceil($page);

$limit = 15; 
$start = $limit; 
$end = $page*$limit-($limit); 

if(isset($_GET['id'])){
   $sql = "SELECT * FROM users WHERE id=".$id."";
   $res = mysql_query($sql) or die(mysql_error());
   if(mysql_num_rows($res) == 0){
      echo "Invalid Path!";
   }else {
      $row = mysql_fetch_assoc($res);
      $sql2 = "SELECT * FROM `users` WHERE `id`='".$row['id']."'";
      $res2 = mysql_query($sql2) or die(mysql_error());
      $row2 = mysql_fetch_assoc($res2);
      if($row2['admin'] == 1 && $admin_user_level == 0){
         echo "You do not have permission!";
      }else {
         $amount_check = "SELECT * FROM `users` WHERE `id`='".$id."'"; 
         $amount_check_res = mysql_query($amount_check) or die(mysql_error()); 
         $amount_count = mysql_num_rows($amount_check_res); 
         $pages = ceil($amount_count/$limit); 
         
         $previous = ($page-1 <= 0) ? "« Prev" : "<a href="./index.php?act=browse&page=".($page-1)."">« Prev</a>"; 
         $nextpage = ($page+1 > $pages) ? "Next »" : "<a href="./index.php?act=browse&page=".($page+1)."">Next »</a>"; 
         echo "<tr><td align="right" colspan="2"> ";
         echo "Pages: ";
         echo $previous; 
         for($i=1;$i<=$pages;$i++){ 
             $href = ($page == $i) ? " ".$i." " : " <a href="./index.php?act=browse&page=".$i."">".$i."</a> "; 
     
             echo $href; 
         } 
         echo $nextpage; 
         echo "</td></tr> ";
         $select_sql = "SELECT * FROM `users` WHERE `id`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; 
         $select_res = mysql_query($select_sql) or die(mysql_error()); 
         
         while($rowr = mysql_fetch_assoc($select_res)){
            echo "<tr><td class ="forum_header">".$rowr['username']."</td></tr> ";
         }
      }
   }
}else{
   echo "Invalid Path!";
}

?>

 

if it's not work, explain what the function mss does

Link to comment
Share on other sites

It was the admin_user_level section.

 

<?php

$id = mss($_GET['id']);
$page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; 
$page = ceil($page);

$limit = 15; 
$start = $limit; 
$end = $page*$limit-($limit); 

if(isset($_GET['id'])){
   $sql = "SELECT * FROM users WHERE id=".$id."";
   $res = mysql_query($sql) or die(mysql_error());
   if(mysql_num_rows($res) == 0){
      echo "Invalid Path!";
   }else {
      $row = mysql_fetch_assoc($res);
      $sql2 = "SELECT * FROM `users` WHERE `id`='".$row['id']."'";
      $res2 = mysql_query($sql2) or die(mysql_error());
      $row2 = mysql_fetch_assoc($res2);
      if($row2['admin'] == 1 && $admin_user_level == 0){
         echo "You do not have permission!";
      }else {
         $amount_check = "SELECT * FROM `users` WHERE `id`='".$id."'"; 
         $amount_check_res = mysql_query($amount_check) or die(mysql_error()); 
         $amount_count = mysql_num_rows($amount_check_res); 
         $pages = ceil($amount_count/$limit); 
         
         $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=browse&page=".($page-1)."\">« Prev</a>"; 
         $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=browse&page=".($page+1)."\">Next »</a>"; 
         echo "<tr><td align=\"right\" colspan=\"2\">\n";
         echo "Pages: ";
         echo $previous; 
         for($i=1;$i<=$pages;$i++){ 
             $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=browse&page=".$i."\">".$i."</a> "; 
     
             echo $href; 
         } 
         echo $nextpage; 
         echo "</td></tr>\n";
         $select_sql = "SELECT * FROM `users` WHERE `id`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; 
         $select_res = mysql_query($select_sql) or die(mysql_error()); 
         
         while($rowr = mysql_fetch_assoc($select_res)){
            echo "<tr><td class =\"forum_header\">".$rowr['username']."</td></tr>\n";
         }
      }
   }
}else{
   echo "Invalid Path!";
}

?>

 

Erm.. So.. How come it still won't show anything up?

Link to comment
Share on other sites

i can't see any problems here...

umm are you sure you got rows on your users tables?

 

if yes, try this and post here the output:

<?php

$id = mss($_GET['id']);
$page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; 
$page = ceil($page);

$limit = 15; 
$start = $limit; 
$end = $page*$limit-($limit); 

if(isset($_GET['id'])){
   $sql = "SELECT * FROM users WHERE id=".$id."";
   $res = mysql_query($sql) or die(mysql_error());
   if(mysql_num_rows($res) == 0){
      echo "Invalid Path!";
      echo "<br> no rows";
   }else {
      $row = mysql_fetch_assoc($res);
      $sql2 = "SELECT * FROM `users` WHERE `id`='".$row['id']."'";
      $res2 = mysql_query($sql2) or die(mysql_error());
      $row2 = mysql_fetch_assoc($res2);
      if($row2['admin'] == 1 && $admin_user_level == 0){
         echo "You do not have permission!";
      }else {
         $amount_check = "SELECT * FROM `users` WHERE `id`='".$id."'"; 
         $amount_check_res = mysql_query($amount_check) or die(mysql_error()); 
         $amount_count = mysql_num_rows($amount_check_res); 
         $pages = ceil($amount_count/$limit); 
         
         $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=browse&page=".($page-1)."\">« Prev</a>"; 
         $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=browse&page=".($page+1)."\">Next »</a>"; 
         echo "<tr><td align=\"right\" colspan=\"2\">\n";
         echo "Pages: ";
         echo $previous; 
         for($i=1;$i<=$pages;$i++){ 
             $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=browse&page=".$i."\">".$i."</a> "; 
     
             echo $href; 
         } 
         echo $nextpage; 
         echo "</td></tr>\n";
         $select_sql = "SELECT * FROM `users` WHERE `id`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; 
         $select_res = mysql_query($select_sql) or die(mysql_error()); 
         
         while($rowr = mysql_fetch_assoc($select_res)){
            echo "<tr><td class =\"forum_header\">".$rowr['username']."</td></tr>\n";
         }
      }
   }
}else{
   echo "Invalid Path!";
   echo "<br> no id";
}

?>

 

if the ouput will be "Invalid Path! no rows"

so you dont have rows in your DB,

 

if it will be "Invalid Path! no id"

so i think the problem is in mss function

Link to comment
Share on other sites

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.