Jump to content

Page Separation Problem


quantum_leap

Recommended Posts

Hi, to everyone, this is my first post in the forum. I am a designer with very basic understanding of PHP. I have designed a website for a real estate agency that I am running. I have passed over the design to a local company and they have provided me with an offline software solution where I keep all records of clients and properties with the software being able to update the website records as well, through PHP and MySQL. Their support has been dreadful to say the least, basically they have left me helpless trying to solve issues myself. One issue I am trying to solve is on the results page. The search property form calls a search_results.php page that includes a page_separation.inc file inside the code. I believe that file is the source of the problem. All results are displayed correctly, 10 results in a row. I can recognize the code inside page_separation.inc where this is happening. The problem is that when I click on the next button instead of displaying the next 10 results, it displays all available properties in the particular area/city they user is searching, rendering results confusing for users. I believe the source of evil is in that page_separation.inc file at the point where it renders the url, something is going wrong there. So I am posting the contents of the code in case someone can have a look and help me, if it's possible. Thank you!

 

<?
function get_page($page, $total, $in_page) {
  if ($page<0)
    return 0;
  elseif ($total>0) {
    $max = $total/$in_page;
    if (intval($max)==$max)
      $max = intval($max)-1;
    else
      $max = intval($max);
    if ($page>$max)
      return $max;
    else
      return $page;
    }
  else
    return 0;
  }

function draw_bar ($page, $total, $in_page, $url) {
  $page = get_page($page, $total, $in_page);

  if ($total>0 && intval($total/$in_page)>0) {
    $start=$page-2; $end=$page+2;
    if ($start<0) {
      $start=0;
      $end=$start+4;
      };
    $end1 = intval(($total-1)/$in_page);
    if ($end>$end1 && $start>$end-$end1) {
      $end=$end1;
      $start=$end-4;
      }
    elseif ($end>$end1) {
      $end=$end1;
      $start=0;
      };

    if ($start>0)
      $nav_panel[] = "<a href=".$url."0 class=pages><< áñ÷Þ</a>";
    if ($page>$start)
      $nav_panel[] = "<a href=$url". ($page-1). " class=pages><< </a>";
    for ($a=$start; $a<=$end; $a++) {
      if ($a==$page)
        $nav_panel[] = "<b>". ($a+1). "</b>";
      else
        $nav_panel[] = "<a href=$url$a class=pages>". ($a+1). "</a>";
      };
    if ($page<$end)
      $nav_panel[] = "<a href=$url". ($page+1) ." class=pages> >></a>";

    return implode(" ", $nav_panel);
    };
  }

function get_limit ($page, $total, $in_page) {
  $page = get_page ($page, $total, $in_page);
  if ($total>0) {
    if (intval($total/$in_page)==0)
      return "";
    elseif ($page>0)
      return " LIMIT ". ($page*$in_page). ",$in_page";
    else
      return " LIMIT $in_page";
    }
  else
    return "";
  }

function get_count_limit ($page, $total, $in_page) {
  $page = get_page ($page, $total, $in_page);
  return $page*$in_page;
  } 

Link to comment
https://forums.phpfreaks.com/topic/162625-page-separation-problem/
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.