I cant pass to second page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
0dm38324mh
Forum Newbie
Posts: 1
Joined: Sat Mar 20, 2010 8:29 am

I cant pass to second page

Post by 0dm38324mh »

Where am I doing wrong?

I can only see search results on FIRST page, second page shows no data.
I can see page counts to 5 but when I click on next page,, I see no results.
What is wrong here?

Code: Select all

<? include("include/escape.php");?>
<? include("include/all.php");?>
<? include("include/lang.php");?>
 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META NAME="keywords" CONTENT="<?=(str_replace('"', """,stripslashes($SiteKeywords)))?>">
<META NAME="description" CONTENT="<?=(str_replace('"', """,stripslashes($SiteDesicription)))?>">
<title><?=(str_replace('"', """,stripslashes($SiteTitle)))?></title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<link href="style/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="js/lib.js"></script>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="<?=($SiteBackColor)?>">&nbsp;</td>
    <td width="15">&nbsp;</td>
    <td width="770" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="310"><? include("top.php");?></td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="189" valign="top"><? include("left.php");?></td>
            <td width="4"><img src="images/spacer.gif" width="1" height="1"></td>
            <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="4">
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td bgcolor="<?=($MenuColor)?>"><table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="3"><img src="images/spacer.gif" width="1" height="1"></td>
                          <td class="FontWhiteBold"><?=($_SESSION['EmlakSearch'])?></td>
                        </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td height="10"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  <tr>
                    <td><table width="100%" height="47" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <?
                          $x=1;
                          $t = 1;
                          
                             $CityID = "";
                             $township_id = "";
                             $EstateStatus = "";
                             $EstateType = "";
                             if (toGet($_GET['City'], $_POST['City']) != '-1' && toGet($_GET['City'], $_POST['City']) != '') {
                                  $CityID = " and CityID='".toGet($_GET['City'], $_POST['City'])."'";
                                  $SearchCityID = toGet($_GET['City'], $_POST['City']);
                                 }
                             if (toGet($_GET['township_id'], $_POST['township_id']) != '-1' && toGet($_GET['township_id'], $_POST['township_id']) != '') {
                                  $township_id = " and TownShipID='".toGet($_GET['township_id'], $_POST['township_id'])."'";
                                  $Searchtownship_id = toGet($_GET['township_id'], $_POST['township_id']);
                                 }
                            
                                 
                             if (toGet($_GET['EstateStatus'], $_POST['EstateStatus']) != '-1' && toGet($_GET['EstateStatus'], $_POST['EstateStatus']) != '') {
                                 $EstateStatus = " and EstateStatus='".toGet($_GET['EstateStatus'], $_POST['EstateStatus'])."'"; 
                                 $SearchEstateStatus = toGet($_GET['EstateStatus'], $_POST['EstateStatus']);
                                 }
                             
                             if (toGet($_GET['EstateType'], $_POST['EstateType']) != '-1' && toGet($_GET['EstateType'], $_POST['EstateType']) != '') {
                                 $EstateType = " and EstateType='".toGet($_GET['EstateType'], $_POST['EstateType'])."'"; 
                                 $SearchEstateType = toGet($_GET['EstateType'], $_POST['EstateType']);
                                 }           
                            
                             
                             if (toGet($_GET['m_min'], $_POST['m_min']) != "".$_SESSION['PWith']."" && toGet($_GET['m_max'], $_POST['m_max']) != "".$_SESSION['PBetween']."") {
                                 $s_meter = "and SquareMeter>=".toGet($_GET['m_min'], $_POST['m_min'])." and SquareMeter<=".toGet($_GET['m_max'], $_POST['m_max']);
                                 $SearchSquareMeterMin = toGet($_GET['m_min'], $_POST['m_min']);
                                 $SearchSquareMeterMax = toGet($_GET['m_max'], $_POST['m_max']);
                                }
                            
                             if (toGet($_GET['p_min'], $_POST['p_min']) != "".$_SESSION['PWith']."" && toGet($_GET['p_max'], $_POST['p_max']) != "".$_SESSION['PBetween']."") {
                                 $price = "and RentPrice>=".toGet($_GET['p_min'], $_POST['p_min'])." and RentPrice<=".toGet($_GET['p_max'], $_POST['p_max']);
                                 $SearchSquarePriceMin = toGet($_GET['p_min'], $_POST['p_min']);
                                 $SearchSquarePriceMax = toGet($_GET['p_max'], $_POST['p_max']);
                                }
                            
                            
                             $sql = "select count(*) as count_row from t_advert where Visible=1 ".($CityID)." ".($township_id)." ".($EstateStatus)." ".($EstateType)." ".($s_meter)." ".($price)."";    
                             $record_count = CountRow($sql);
                             
                             $record_per_page = 0;
                             if ($record_count > 0) {
                                $record_per_page = GetName("select * from t_count_page","SearchCount");
                                $page_count = ceil($record_count/$record_per_page);
                                }
                                 
                                    
                                                  
                          $sql = "select 
                                    t1.*, ".GetCurrency($_SESSION['LangCurrency'])."
                                    t2.Name as estate_type,
                                    t3.Name as estate_status,
                                    t4.Name as estate_township,
                                    t6.Currency as estate_rent_currency,
                                    t7.Images as estate_images,
                                    t8.Name as estate_city
                                 from t_advert t1
                                    inner join t_properties t2 on t2.PageType='EstateType'
                                    inner join t_properties t3 on t3.PageType='EstateStatus'
                                    inner join t_properties t4 on t4.PageType='TownShip'
                                    inner join t_exchange t6 on t6.Currency=t1.RentCurrency
                                    inner join t_advert_images t7 on t7.ParentID=t1.ID
                                    inner join t_properties t8 on t8.PageType='City'
                                where 
                                    t2.ItemID   = t1.EstateType and t2.PageLang='".$_SESSION['Lang']."' and 
                                    t3.ItemID   = t1.EstateStatus and t3.PageLang='".$_SESSION['Lang']."' and 
                                    t4.ID       = t1.TownShipID and
                                    t6.Currency = t1.RentCurrency and 
                                    t7.ParentID = t1.ID and t7.Seq = (select min(Seq) from t_advert_images where Visible='1' and ParentID=t1.ID group by Seq LIMIT 0,1) and 
                                    t8.ID       = t1.CityID and
                                    t1.Visible='1' ".($CityID)." ".($township_id)." ".($EstateStatus)." ".($EstateType)." ".($s_meter)." ".($price)." ".($s_meter)." ".($price)." order by ListPrice limit ".($_GET['page_no']*$record_per_page).",".$record_per_page;
                                    
                           $qrDisplay = mysql_query($sql);
                           while($rsDisplay = mysql_fetch_array($qrDisplay)) {
                        ?>
                          <td valign="top"><table width="285" height="126" border="0" cellpadding="0" cellspacing="0">
                              <tr>
                                <td valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                      <td height="19"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                      <tr>
                                                        <td width="2" bgcolor="#F9F9F9"><img src="images/ok.gif" width="15" height="18"></td>
                                                        <td height="18" bgcolor="F2F1F1"><a href="advert_detail.php?ID=<?=($rsDisplay['ID'])?>" class="BlackLink"><font color="#666666"><b><?=($rsDisplay['estate_status'] . " - ".  $rsDisplay['estate_type'])?></b></font></a></td>
                                                      </tr>
                                                  </table></td>
                                                </tr>
                                                <tr>
                                                  <td height="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                                </tr>
                                            </table></td>
                                            <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                          </tr>
                                      </table></td>
                                    </tr>
                                    <tr>
                                        <td height="7"><img src="images/spacer.gif" width="1" height="1"></td>
                                    </tr>
                                    <tr>
                                      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="120" valign="top"><a href="advert_detail.php?ID=<?=($rsDisplay['ID'])?>">
                                          <? if ($rsDisplay['AdvertType'] == 2) { ?>
                                          <img src="sold.php?str=<?=($_SESSION['Sold'])?>&img=images/estate/<?=($rsDisplay['estate_images'])?>_small.jpg" border="0">
                                          <? } else { ?>
                                          <img src="images/estate/<?=($rsDisplay['estate_images'])?>_small.jpg" width="120" height="90" border="0">
                                          <? } ?>
                                          </a></td>
                                          <td width="5"><img src="images/spacer.gif" width="1" height="1"></td>
                                          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                      <tr>
                                                        <td width="55" height="19" class="BrownText10"><?=($_SESSION['CityName'])?></td>
                                                        <td width="8" class="BrownText10">:</td>
                                                        <td class="BrownTextRegular"><?=($rsDisplay['estate_city'])?></td>
                                                      </tr>
                                                      <tr>
                                                        <td height="19" class="BrownText10"><?=($_SESSION['TownShip'])?></td>
                                                        <td class="BrownText10">:</td>
                                                        <td class="BrownTextRegular"><?=($rsDisplay['estate_township'])?></td>
                                                      </tr>
                                                      <tr>
                                                        <td height="19" class="BrownText10"><?=($_SESSION['SquareMeter'])?></td>
                                                        <td class="BrownText10">:</td>
                                                        <td class="BrownTextRegular"><?=($rsDisplay['SquareMeter']. " m<sup>2</sup>")?></td>
                                                      </tr>
                                                      <tr>
                                                        <td height="19" class="BrownText10"><?=($_SESSION['Price'])?></td>
                                                        <td class="BrownText10">:</td>
                                                        <td class="BrownTextRegular"><?=(number_format($rsDisplay['RentPrice']) . " " . $rsDisplay['RentCurrency'])?></td>
                                                      </tr>
                                                  </table></td>
                                                </tr>
                                              </table></td>
                                            </tr>
                                            <tr>
                                              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td align="right"><a href="advert_detail.php?ID=<?=($rsDisplay['ID'])?>" class="BlackLink"><font color="#303030"><u><?=($_SESSION['DetailAdvertInfo'])?></u></font></a></td>
                                                  <td width="12"><img src="images/ok_details.gif" width="15" height="12"></td>
                                                </tr>
                                              </table></td>
                                            </tr>
                                          </table></td>
                                        </tr>
                                      </table></td>
                                    </tr>
                                    <tr>
                                      <td height="10"><img src="images/spacer.gif" width="1" height="1"></td>
                                    </tr>
                                </table></td>
                                <? if($t != 2) { ?>
                                <td width="10" valign="top"><img src="images/spacer.gif" width="1" height="1"></td>
                                <? 
                                  $t++;
                                  } else {
                                  $t = 1;
                                  }
                                  ?>
                                      <tr>
                                        </table>
                                      <?    
                                    if(($x % 2) == 0) {
                                        echo "</tr>\n";
                                        echo "<tr>\n";
                                        }
                                 
                                 $x++;
                                 }      
                                ?></tr>
                                <? if ($record_count == 0) { ?>
                                <tr>
                                    <td align="center" class="BrownTextRegular"><?=($_SESSION['SearchNotFound'])?></td>
                                </tr>
                                <? } ?>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
              <? if ($page_count>1) { ?>
              <?
                  $City = $SearchCityID?"&City=".$SearchCityID:"";
                  $township_id = $Searchtownship_id?"&township_id=".$Searchtownship_id:"";
                  $EstateStatus = $SearchEstateStatus?"&EstateStatus=".$SearchEstateStatus:"";
                  $EstateType = $SearchEstateType?"&EstateType=".$SearchEstateType:"";
                  
                  $m_min = $SearchSquareMeterMin?"&m_min=".$SearchSquareMeterMin:"";
                  $m_max = $SearchSquareMeterMax?"&m_max=".$SearchSquareMeterMax:"";
                  $p_min = $SearchSquarePriceMin?"&p_min=".$SearchSquarePriceMin:"";
                  $p_max = $SearchSquarePriceMax?"&p_max=".$SearchSquarePriceMax:"";
                  
                  $url = "search.php?s=1".($City)."".($township_id)."".($EstateStatus)."".($EstateType)."".($m_min)."".($m_max)."".($p_min)."".($p_max);
                  
              ?>
              <tr>
                <td class="BrownTextRegular"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  <tr>
                    <td height="6"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  <tr>
                    <td bgcolor="CECCCC"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                      <tr>
                        <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                          <tr>
                            <td bgcolor="F2F1F1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="100" bgcolor="#FFFFFF" class="BrownTextRegular10">&nbsp;<? 
                                                                                                    if ($page_count>1) {
                                                                                                       echo $_SESSION['SearchPage']. " ";
                                                                                                       echo $_GET['page_no'] + 1 . " / " . $page_count;
                                                                                                      } 
                                                                                                    ?>      
                                </td>
                                <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                <td align="center"><table border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                    <td bgcolor="#FFFFFF" <?=($_GET['page_no']==0?"width=\"80\"":"")?>>
                                    <? if ($_GET['page_no'] > 0) { ?>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="7"><img src="images/spacer.gif" width="1" height="1"></td>
                                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td width="15"><img src="images/pre_ok.gif" width="15" height="16"></td>
                                            <td class="BrownTextRegular10"><a href="<?=($url)?>&page_no=<?=($_GET['page_no'] - 1);?>" class="BlackLink"><font color="#303030"><?=($_SESSION['SearchPreviousPage'])?></font></a></td>
                                          </tr>
                                        </table></td>
                                        <td width="7"><img src="images/spacer.gif" width="1" height="1"></td>
                                      </tr>
                                    </table>
                                    <? } ?>
                                    </td>
                                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                        <td bgcolor="#FFFFFF"><table width="100%" height="18" border="0" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <? 
                                               if ($page_count>1) {
                                                   for ($m=1;$m<=$page_count;$m++) {
                                            ?>
                                                    <td width="16" align="center" class="BrownTextRegular10"><?
                                                                                                                if($m-1==$_GET['page_no']) {
                                                                                                                    echo "<b>".$m."</b>"; 
                                                                                                                    } else {
                                                                                                                    echo "<a href='".$url."&page_no=".($m-1)."' class='BlackLink'><u>".$m."</u></a>";
                                                                                                                }   
                                                                                                                ?></td>
                                                    <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                             <? 
                                                    } //for ($m=1;$m<=$page_count;$m++) {
                                              } //if ($page_count>1) {
                                             ?> 
                                          </tr>
                                        </table></td>
                                        <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                      </tr>
                                    </table></td>
                                    <? if ($_GET['page_no'] < $page_count - 1) { ?>
                                           <td bgcolor="#FFFFFF">   
                                        <? } else { ?>
                                            <td bgcolor="#FFFFFF" width="80">
                                        <? } ?>
                                    <? if ($_GET['page_no'] < $page_count - 1) { ?>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="7"><img src="images/spacer.gif" width="1" height="1"></td>
                                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td align="right" class="BrownTextRegular10"><a href="<?=($url)?>&page_no=<?=($_GET['page_no'] + 1)?>" class="BlackLink"><font color="#303030"><?=($_SESSION['SearchNextPage'])?></font></a></td>
                                            <td width="15"><img src="images/ok_next.gif" width="15" height="16"></td>
                                          </tr>
                                        </table></td>
                                        <td width="7"><img src="images/spacer.gif" width="1" height="1"></td>
                                      </tr>
                                    </table>
                                    <? } ?>
                                    </td>
                                    <td width="1" bgcolor="CECCCC"><img src="images/spacer.gif" width="1" height="1"></td>
                                  </tr>
                                </table></td>
                                <td width="100">&nbsp;</td>
                              </tr>
                            </table></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
              <? } ?>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><? include("footer.php")?></td>
      </tr>
    </table></td>
    <td width="15">&nbsp;</td>
    <td bgcolor="<?=($SiteBackColor)?>">&nbsp;</td>
  </tr>
</table>
</body>
</html>
 
Post Reply