0

guys i am really stuck in this tried couples of ways but didnt get it right please help.My pagiantion is working fine and great untill i specfies WHERE CLAUSE in it.I am trying to have a text field so that if a user enter the interger for class search e.g 8.Pagination search records WHERE class is 8 BUT it show me record only on the first page but when i turn to second page it show a empty page.Please Help me

<?php
     
	            session_start();
	            mysql_connect("localhost","root","");
				mysql_select_db("project");
               
			   
               $_SESSION['class'] = $_POST['test'];
	       echo    $class = $_SESSION['class'];
	            
				$per_page = 6;
				$pages_query = mysql_query("SELECT COUNT('id') FROM `stu_info`[B] WHERE `classess` = '$class'[/B]");
               $pages = ceil(mysql_result($pages_query, 0)/$per_page);
               $page = (isset($_GET['page'])) ? (int)$_GET['page'] :1 ;
			   $start = ($page-1)* $per_page;
					 
			  
			  $query = mysql_query("SELECT * FROM `stu_info`[B] WHERE classess = '$class'[/B] LIMIT $start, $per_page");
	  


					while($query_row=mysql_fetch_assoc($query))
					
					{
					
				 echo '<p>'.$id = $query_row['id'].'<p/>';
					
					}
					
		if($pages >=1 && $page<$pages){
		
		for($x=1; $x<=$pages; $x++){
		echo ($x == $page)? '<strong><a href="?page='.$x.'">'.$x.'</strong></a> ': '<a href="?page='.$x.'">'.$x.'</a> ';
		
		}}
		
	 
?>
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by ppetree
0

First thing that jumped out at me was that $pages_query had no mysql_query() but you were doing $pages = ceil(mysql_result($pages_query, 0)/$per_page);

Other than that, I think your whole $pages_query is unnecessary. I think you can use LIMIT in your second query and it will skip the first n results.

This topic has been dead for over six months. 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.