Jump to content

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

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.