Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Page Separation Problem
Old 06-17-2009, 03:29 PM Page Separation Problem
Junior Talker

Posts: 3
Trades: 0
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!

PHP Code:
<?
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>&& 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>&lt;&lt; αρχή</a>";
    if (
$page>$start)
      
$nav_panel[] = "<a href=$url". ($page-1). " class=pages>&lt;&lt; </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> &gt;&gt;</a>";

    return 
implode("&nbsp;"$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;
  }
quantum_leap is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-22-2009, 12:44 PM Re: Page Separation Problem
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Can you post the segment of code where this is called?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-22-2009, 03:24 PM Re: Page Separation Problem
Junior Talker

Posts: 3
Trades: 0
It's called from the search_results.php somewhere in the middle (include ("page_separation.inc");)

PHP Code:
<?
include('includes/config.php');
include(
'includes/lang.php');
$region="";
if(
$_GET[main]>0){$region=$_GET[main];}
if(
$_GET[menu1]>0){$region=$_GET[menu1];}
if(
$_GET[menu2]>0){$region=$_GET[menu2];}
    if (!
$sort$sort="price";
    if (!
$squere1$squere1=0;
    if (!
$squere2$squere2=99999999;
    if (!
$price1$price1=0;
    if (!
$price2$price2=999999999;
    if (!
$rooms_n1$rooms_n1=0;
    if (!
$rooms_n2$rooms_n2=99;

$price1=preg_replace("/,|\./","",$price1);
$price2=preg_replace("/,|\./","",$price2);
$rooms_n1=preg_replace("/,|\./","",$rooms_n1);
$rooms_n2=preg_replace("/,|\./","",$rooms_n2);

db_connect();

$rt=strlen($_GET[real_type]);
if(
$rt==0)
    {
$where_rt="";
    
$real_type_name=$aLang[any];
    }
elseif((
$rt>=1) and ($rt<=2))
    {
$where_rt=" AND angelies.real_type like ('".$_GET[real_type]."%')"$type_id="like ('".$_GET[real_type]."%')";
    
$real_type_name=$request_rt[$_GET[real_type]];
    }
else 
    {
    
$where_rt="AND angelies.real_type IN ('".$_GET[real_type]."')";$type_id"IN ('".$_GET[real_type]."')";
    
    
$array=explode("','",$_GET[real_type]);
    foreach (
$array as $id){$real_type_name.=' '.$request_rt[$id].', ';}    
    
    }    


/*    
    if($type_id==""){$real_type_name=$aLang[any];}
    else{$sql="SELECT type_id,$LTypename FROM real_type WHERE type_id " .$type_id;
    $result = mysql_query ($sql);
    while ($row = mysql_fetch_array($result)){$real_type_names[$i] = $row ["type_name"];$i++;}
    $real_type_name=implode(", ", $real_type_names);
    }
*/

$sql_from="FROM
angelies
Inner Join regions ON angelies.region = regions.reg_id
Inner Join real_type ON angelies.real_type = real_type.type_id"
;
if(isset(
$_GET[deal_type]))
{
$sql_where=" WHERE
 angelies.company= '"
.$agency_id."' 
  AND angelies.status = 1" 
.(($region!="")?" AND angelies.region LIKE '".$region."%'":""). 
" AND angelies.deal_type = '".$_GET[deal_type]."'"
.$where_rt
 
" AND angelies.squere BETWEEN ".$squere1." AND ".$squere2.
 AND angelies.price BETWEEN "
.$price1." AND ".$price2." AND angelies.rooms_n BETWEEN ".$rooms_n1." AND ".$rooms_n2;
}
else {
$sql_where="WHERE  angelies.company= '".$agency_id."' AND angelies.status = 1 AND prosfora > 0" ;}
if(
$_GET[kod]!=""){$sql_where="WHERE  angelies.company= '".$agency_id."' AND angelies.status = 1 AND kod like '!$_GET[kod]'escape '!'" ;}

//

include ("page_separation.inc"); // (RV)
$in_page 10// number of rows in page (PV)
$amount = @mysql_result(mysql_query("SELECT count(real_id) FROM angelies $sql_where"),0); //  Numbers of Row (PV)

    
$sql="SELECT real_id,region,$LSubregion,company,real_type,deal_type,squere,rooms_n,rooms_t,age,price,floor,epipedo,status,kod,DATE_FORMAT(date,'%d-%m-%Y') as date_formated,type_id,$LTypename,reg_id,$LRegion,lift,parking,view,therm,`condition`,sxedio,apox,dei,gonia,idrevci,aposiki,tzaki,furniture,distance_from_sea,distance_from_airport,distance_from_port,distance_from_nearest_city,distance_from_metro  
$sql_from $sql_where"get_limit($page$amount$in_page); // PV
$result mysql_query ($sql);
$request_info="";
//if($region){$request_info= $regions_array[$region].', ';}
        
if($price2==999999999$price2="";
    if(
$squere2==99999999$squere2="";
        
$squere1_formated=number_format ($squere1,0,".",".");
        
$squere2_formated=number_format ($squere2,0,".",".");
        
$price1_formated=number_format ($price1,0,".",".");
        
$price2_formated=number_format ($price2,0,".",".");
//request => real_type



$request_info.=(isset($_GET[deal_type])?($request_dt[$_GET[deal_type]]):($reqest_dt[3]));

$request_info.= "$real_type_name ";
    if(
$squere1 AND squere2) {$request_info.= ", $squere1_formated - $squere2_formated $aLang[sq]";} 
    else {
            if(
$squere1)$request_info.= ','.$aLang[from].$squere1_formated.' '.$aLang[sq];
            if(
$squere2$request_info.=','.$aLang[to].$squere2_formated.' '.$aLang[sq];
        };        
if(
$price1 AND $price2){$request_info.=', '.$aLang[price].': '.$price1_formated.' - '.$price2_formated.'€';} 
else {
        if(
$price1) {$request_info.=', '.$aLang[price].': '.$price1_formated.'€';}
        if(
$price2) {$request_info.=', '.$aLang[price].': '.$price2_formated.'€';;}
    };

if (
$amount==0){}
//
else{
$i=0;
while (
$row mysql_fetch_array($result)){
$real_id $row ["real_id"];
$kod $row ["kod"];
$region_name $row ["reg_name"];
$subregion $row ["subregion"];
$deal_type $row ["deal_type"];
$real_type_name $row ["type_name"];
$squere number_format ($row ["squere"],0,".",".");
$rooms_n $row ["rooms_n"];
$rooms_t $row ["rooms_t"];
$age $row ["age"];
$price number_format ($row ["price"],0,".",".");
$floor $row ["floor"];
$epipedo $row ["epipedo"];
$date $row ["date_formated"];
$lift $row ["lift"];
$parking $row ["parking"];
$view $row ["view"];
$condition $row ["condition"];
$therm $row ["therm"];
$sxedio $row ["sxedio"];
$apox $row ["apox"];
$dei $row ["dei"];
$gonia $row ["gonia"];
$idrevci $row ["idrevci"];
//
$aposiki=$row[aposiki];
$tzaki=$row[tzaki];
$furniture=$row[furniture];
//
$distance_from_sea=$row[distance_from_sea];
$distance_from_airport=$row[distance_from_airport];
$distance_from_port=$row[distance_from_port];
$distance_from_nearest_city=$row[distance_from_nearest_city];
$distance_from_metro=$row[distance_from_metro];    
//form akinita info array    
$akinita[$i][region]=$region_name.' '.$subregion;
if (
$price) {$akinita[$i][price]=$price;}
if (
$kod)   {$akinita[$i][kod]=$kod;}
$akinita[$i]['type'].=$real_type_name
if (
$squere) {$akinita[$i]['square'].=' '.$squere.$aLang[sq];} 
if (
$rooms_n) {$akinita[$i][info].=' '.$rooms_n.' '.$aLang[bedrooms];}
if (
$age==-1) {$akinita[$i][info].=' '.$aLang['new'];} 
elseif (
$age==-2) {$akinita[$i][info].=' '.$aLang[under_constr];}
elseif (
$age==0) {$akinita[$i][info].= "";}
else {
$akinita[$i][info].=' '.$age.' '.$aLang[years_old];} 

if (
$floor_array[$floor]) {$akinita[$i]['floor'].='&nbsp;'.$floor_array[$floor]; }
if(
$epipeda_array[$epipedo]) {$akinita[$i][info].='&nbsp;'.$epipeda_array[$epipedo];} 
if (
$sxedio) {$akinita[$i][info].='&nbsp'$sxedio_array[$sxedio];}
if (
$dei>0) {$akinita[$i][info].=$aLang[electr_spl].' '$plus_array[$dei]; }
if (
$apox>0) {$akinita[$i][info].=$aLang[sewerage].': '.$plus_array[$apox]; }
if (
$idrevci>0) {$akinita[$i][info].=$aLang[water_spl].': '.$plus_array[$idrevci];}
if (
$gonia>0) {$akinita[$i][info].=$aLang[corner].': '.$plus_array[$gonia];}
if (
$therm>0) {$akinita[$i][info].=' '.$heating_array[$therm];}
if (
$lift==1) {$akinita[$i][info].=' '.$aLang[lift];}
if (
$parking==1) {$akinita[$i][info].= ' '.$aLang[parking]; }
if (
$aposiki==1) {$akinita[$i][info].= ' '.$aLang[aposiki]; }
if (
$tzaki==1) {$akinita[$i][info].= ' '.$aLang[tzaki]; }
if (
$furniture==1) {$akinita[$i][info].= ' '.$aLang[furniture]; }

if (
$view==1) {$akinita[$i][info].= ' '.$aLang[view];}
if (
$condition>0) { $akinita[$i][info].= ' '.$condition_array[$condition];} 

$akinita[$i][id]=$real_id;
if (
file_exists($server_root."/photos/small/$agency_id/$real_id.jpg")) 
{
$akinita[$i][img]= "<img width=135 height=100 class=image src=$server_www/photos/small/$agency_id/$real_id.jpg >";
}
$i++;

if (
$in_page<=$amount)
{
$pages=$aLang[pages].': '.(draw_bar($page$amount$in_page$PHP_SELF."?lang=gr&deal_type=$deal_type&region=$region&real_type=$real_type&squere1=$squere1&squere2=$squere2&price1=$price1&price2=$price2&sort=$sort&page="));}}

?>
Thank you!
quantum_leap is offline
Reply With Quote
View Public Profile
 
Old 06-25-2009, 08:01 PM Re: Page Separation Problem
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
i'm still rather new to php... wondering if it could be the url arguement thats incorrect

PHP Code:
if ($in_page<=$amount)
{
$pages=$aLang[pages].': '.(draw_bar($page$amount$in_page$PHP_SELF."?lang=gr&deal_type=$deal_type&region=$region&real_type=$real_type&squere1=$squere1&squere2=$squere2&price1=$price1&price2=$price2&sort=$sort&page 
can i see a snap shot of the result it dumps out?

Last edited by orionoreo; 06-25-2009 at 08:03 PM..
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 06-26-2009, 03:37 AM Re: Page Separation Problem
Junior Talker

Posts: 3
Trades: 0
Hard to show you cause everything would be in Greek. Basically, after choosing amongst three types of properties(apartments, professional properties, plots), following selection of county, it displays correct results, then clicking on next, it will display all available properties selected from first step(apartments, professional properties, plots) without taking into account the county selection or any following criteria that the user could choose, for instance, suburb and town. You see, what I mean? It seems that it's the url arguement, as you say, don't know how it could be rewritten, though.
quantum_leap is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Page Separation Problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44932 seconds with 12 queries