Jump to content

pagination issues


darknessmdk

Recommended Posts

Hi all, Having a problem with my pagination code. 

 

	if($both == "0"){   

						 $query_count = "SELECT * FROM properties WHERE (city = '$city' OR state = '$state' OR zip = '$zip')AND price BETWEEN '0' AND '$price'";
						} elseif($price == "0") {

							$query_count = "SELECT * FROM properties WHERE (city = '$city' OR state = '$state' OR zip = '$zip')AND  beds = '$beds' AND baths = '$baths'";

						} elseif($beds == "0") {

							$query_count = "SELECT * FROM properties WHERE (city = '$city' OR state = '$state' OR zip = '$zip')AND baths = '$baths' AND price BETWEEN '0' AND '$price'";

						} elseif($baths == "0") {

							$query_count = "SELECT * FROM properties WHERE (city = '$city' OR state = '$state' OR zip = '$zip')AND beds = '$beds' AND price BETWEEN '0' AND '$price'";

				          }else{

				$query_count = "SELECT * FROM properties WHERE city = '$city' AND beds = '$beds' AND baths = '$baths' AND price BETWEEN '0' AND '$price' OR state = '$state' AND beds = '$beds' AND baths = '$baths' AND price BETWEEN '0' AND '$price' OR zip = '$zip' AND beds = '$beds' AND baths = '$baths' AND price BETWEEN '0' AND '$price'"; 

			  	} 

				$limit = 2;
				$result_count = mysql_query($query_count);    

				$totalrows = mysql_num_rows($result_count);


				if(empty($page)){

					$page = 1;

				}
					$pages = ceil($totalrows / $limit);

				$limitvalue = $page * $limit - ($limit); 

			$query_order = " ORDER BY date DESC LIMIT $limitvalue, $limit"; 

				$query  = $query_count."".$query_order ;  
				echo $query_count;

				$result = mysql_query($query) or die("Error: " . mysql_error()); 

 

 

It lists the first page of results fine, when you click on next or a page number it shows no results. This started happening after I added the if else statements. I have it printing out my sql statment and I noticed that its cutting off half of the statement. Ive never had anything like this happen before.

Link to comment
https://forums.phpfreaks.com/topic/55610-pagination-issues/
Share on other sites

Set a session with the page name and make a if else statement for the session :).

 

$_SESSION['page'] = '1'; is page one

$_SESSION['page'] = '2'; is page two

etc etc

 

You get it? Perhaps visit php.net for more information on sessions. Never use hidden form objects, but use sessions instead.

 

FD

Link to comment
https://forums.phpfreaks.com/topic/55610-pagination-issues/#findComment-274839
Share on other sites

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.