Jump to content

Using pagination with post?


feri_soft

Recommended Posts

I have a form with many option and i get the variables from those options with $_request.When i try to create a pagination i get the exact number of pages but every page except the first one is totaly empty?

Here is what i use:

[code]if(!isset($_GET['page'])){     

$page = 1;
}else{

$page = $_GET['page'];
}

$max_results = 1;                                       

$from = (($page * $max_results) - $max_results); 
$q = mysql_query("some select $whereclause LIMIT $from,$max_results");
  if(!$q) die(mysql_error());
    $err = mysql_num_rows($q);
      if($err == 0){ echo("dfgdfg);}




while($row = mysql_fetch_array($q, MYSQL_ASSOC))
{
sdfsdfsdff
}

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM dfgfdg $whereclause"),0);

$total_pages = ceil($total_results/$max_results);

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){

echo "$i ";
}else{                 

echo "<a href='?page=$i'>$i</a> "; 
} }              [/code]
Link to comment
https://forums.phpfreaks.com/topic/26152-using-pagination-with-post/
Share on other sites

Well, there are errors in your code, but I don't know if they are causing that problem or not.

[code]if($err == 0){ echo("dfgdfg);}[/code]
That echo statement is not formatted correctly.

[code]sdfsdfsdff[/code]
I'm surprised the page even runs with that

I suggest you echo $q to the page to ensure the queries are what you expect them to be.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.