dongliugu8843 2016-03-03 11:07
浏览 49

每页结果PHP

I currently pull through data from a soap feed using this PHP, is there anyway for me to have the results ordered from high to low using the data from $weekrent?

Any help would be great! Here is my PHP code:

    <?php

$wsdl = "http://portal.letmc.com/PropertySearchService.asmx?WSDL";

$client = new SoapClient($wsdl, array ("trace"=>1, "exceptions"=>0));

$strClientID = "{0050-e58a-cd32-3771}";
$strBranchID = "{0004-e58a-cd32-399e}";
$strAreaID = $_GET['area'];
$nMaxResults = $_GET['perpage'];
$nRentMinimum = $_GET['minrent'];
$nRentMaximum = $_GET['maxrent'];
$nMaximumTenants = $_GET['numtennants'];                           

$parameters = array(    "strClientID"=>$strClientID, 
                    "strBranchID"=>$strBranchID, 
                    "strAreaID"=>$strAreaID, 
                    "nMaxResults"=>$nMaxResults,
                    "nRentMinimum"=>$nRentMinimum,
                    "nRentMaximum"=>$nRentMaximum,
                    "nMaximumTenants"=>$nMaximumTenants
                );                          

$values = $client->SearchProperties($parameters);

if(!is_array($values->SearchPropertiesResult->PropertyInfo))
{
    $values->SearchPropertiesResult->PropertyInfo = array($values->SearchPropertiesResult->PropertyInfo);
}

if($values != '')
{

    foreach ($values->SearchPropertiesResult->PropertyInfo as $message)
    {
        $uglyid = $message->ID;
        $id = $message->FriendlyID;
        $mainphoto = $message->MainPhoto->PhotoUrl;
        $furnished = $message->Furnished;
        $addressline1 = $message->Address1;
        $rooms = $message->MaxTenants;
        $rent = $message->Rent;
        $description = $message->Description;
        $isletagreed = $message->IsLetAgreed;
        $facilities = $message->Facilities->FacilityInfo;
        $photos = $message->Photos->PhotoInfo;
        $roomsinfo = $message->Rooms->RoomInfo;
        $facilitiesstring = serialize($facilities);
        $extractnumbers = ereg_replace("[^0-9]", "", $rent);
        $monthrent = ($extractnumbers) / $rooms;
        $monthrentrounded = number_format(($monthrent/100),2);
        $weekrent = ($monthrentrounded) * 12 / 52;
        $weekrentrounded = floor($weekrent * 100) / 100;

        $roomsinfojson = json_encode($roomsinfo);
        $facilitiesjson = json_encode($facilities);
        $roomsinfodouble = (substr_count(strip_tags($roomsinfojson),"Double"));
        $roomsinfosingle = (substr_count(strip_tags($roomsinfojson),"Single"));
        $roomsinfobathroom = (substr_count(strip_tags($roomsinfojson),"Bathroom"));
        $roomsinfoshower = (substr_count(strip_tags($roomsinfojson),"Shower"));
        $facilitiesparking = (substr_count(strip_tags($facilitiesjson),"Parking"));
        $facilitiesgarden = (substr_count(strip_tags($facilitiesjson),"Garden"));

        $totalbathrooms = $roomsinfobathroom + $roomsinfoshower;
        $totalimages = count($photos);

        echo '
        <div class="col-property-box col-property-box-1-3">
                        <div class="owl-property-box">';
                             $i=0; foreach ($photos as $data) { if($i==4) break; echo '<div class="property-grid-box-picture" style="background: url('. $data->PhotoUrl .') center center;"></div>'; $i++; };
                        echo '</div>
                <div class="property-grid-box">
                        <a href="http://www.stla.co.uk/properties/show/?id='. $uglyid .'" class="property-grid-box-title">'. $addressline1 .'</a>
                        <p class="property-grid-box-text">'. limit_words($description,19) .'...</p>
                    <div class="property-grid-box-price">
                        <div class="section group">
                           <div class="col col-property-box-1-2 property-grid-box-price-border-right">
                               <div class="property-grid-box-price-top">£'. $weekrentrounded.'pp</div> <div class="property-grid-box-price-under">Weekly</div>
                           </div>
                           <div class="col col-property-box-1-2">
                               <div class="property-grid-box-price-top">£'. $monthrentrounded .'pp</div> <div class="property-grid-box-price-under">Monthly</div>
                           </div>
                        </div>
                    </div>

                        <div class="property-grid-box-icon-box">
                            <div class="section group">
                           <div class="col col-1-3-border no-left-border">
                            <span class="property-grid-box-number-icon"><center><i class="fa fa-bed"></i></center><div class="property-grid-box-number-text">'. $rooms .'</div></span>
                           </div>
                           <div class="col col-1-3-border">
                            <span class="property-grid-box-number-icon"><center><i class="flaticon-shower5"></i></center><div class="property-grid-box-number-text">'. $totalbathrooms .'</div></span>
                           </div>
                           <div class="col col-1-3-border">
                            <span class="property-grid-box-number-icon"><center><i class="flaticon-beds12"></i></center><div class="property-grid-box-number-text">'. $totalimages .'</div></span>
                           </div>                          
                        </div>
                </div>
                </div>

            </div>
        ';

    }
}

function limit_words($string, $word_limit)
{
    $words = explode(" ",$string);
    return implode(" ",array_splice($words,0,$word_limit));
}

                       ?>
  • 写回答

2条回答 默认 最新

  • dongxin991209 2016-03-03 11:16
    关注

    you can use usort function .. so you get the sorted result

    Read more on php

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题