doupi6737 2016-01-03 11:16
浏览 37

XML PHP Display Loop无法正常工作

ok the XML file is here ► XML Feed Link

The code I have currently is :

<?php 
// FOOTBALL DATAFEED - WINNER
$matchid = $_GET['matchid'];
//$xmlData = 'http://feeds-sports.winner.com/odds_feed?key=get_events_for_type&lang=en&&sb_type_id=19157';
function viewevent($matchid){
    $showdate = date('Y-m-d');
$xmlData = 'http://feeds-sports.winner.com/odds_feed?key=get_all_markets_for_event&lang=en&ev_id='.$matchid;
$xml = simplexml_load_file($xmlData);
$i = 0;
$curdate = date('d/m/Y');
        foreach ($xml->Sport->SBClass->SBType->Ev->Mkt as $event)
    {
        $starttime = $event['start_time'];
        $newline = str_replace('-','/',$starttime);
        $datecount = strlen($starttime);
        $year = substr($newline, 0, 4);
        $month = substr($newline, 5, 2);
        $day = substr($newline, 8, 2);
        $date = $day.'/'.$month.'/'.$year;
        $kickoff = substr($newline, 11, 5);
        $bettype = $event->Mkt['name'];

        if($date == $curdate){
            $eventname = '<strong>'.$event['name'].'</strong> @'.$kickoff.'<br/>'.$bettype;
        } else {
        $eventname = '<strong>'.$event['name'].'</strong> <br /> '.$date.' - @'.$kickoff.'<br />'.$bettype;
        }
        $watch =  "<a href=\"http://sports.winner.co.uk/en/e/".$event->attributes()->{'ev_id'}."\"><img src=\"watchhd.png\" width=\"121\" height=\"45\" alt=\"Watch in HD\" style=\"vertical-align:center;\" /></a>";

        $hometeam = $event->Seln[0]->attributes()->{'name'} .' ('. $event->Seln[0]->attributes()->{'seln_sort'}.') - ';
        $homefodds = $event->Seln[0]->Price['frac_prc'];
        $homedodds = $event->Seln[0]->Price['dec_prc'];
        $homebetref = $event->Seln[0]->Price['bet_ref'];
        $homebetlink = 'http://online.winner.com/promoRedirect?key=ej01MjczMzg5OSZsPTAmcD04MDI1NQ%3D%3D&BET_REF='.$homebetref.'&LANGUAGE_CODE=en';
        $homebet = "<a href=\"".$homebetlink."\"><img src=\"betnow.gif\" /></a>";


        $draw = $event->Seln[1]->attributes()->{'name'} .' ('. $event->Seln[1]->attributes()->{'seln_sort'}.') - ';
        $drawfodds = $event->Seln[1]->Price['frac_prc'];
        $drawdodds = $event->Seln[1]->Price['dec_prc'];
        $drawbetref = $event->Seln[1]->Price['bet_ref'];
        $drawbetlink = 'http://online.winner.com/promoRedirect?key=ej01MjczMzg5OSZsPTAmcD04MDI1NQ%3D%3D&BET_REF='.$drawbetref.'&LANGUAGE_CODE=en';
        $drawbet = "<a href=\"".$drawbetlink."\"><img src=\"betnow.gif\" /></a>";

        $awayteam = $event->Seln[2]->attributes()->{'name'} .' ('. $event->Seln[2]->attributes()->{'seln_sort'}.') - ';
        $awayfodds = $event->Seln[2]->Price['frac_prc'];
        $awaydodds = $event->Seln[2]->Price['dec_prc'];
        $awaybetref = $event->Seln[2]->Price['bet_ref'];
        $awaybetlink = 'http://online.winner.com/promoRedirect?key=ej01MjczMzg5OSZsPTAmcD04MDI1NQ%3D%3D&BET_REF='.$awaybetref.'&LANGUAGE_CODE=en&PRICE_FORMAT=FRAC';
        $awaybet = "<a href=\"".$awaybetlink."\"><img src=\"betnow.gif\" /></a>";


        // Get MATCH ID
        $matchid = $event->EvDetail['br_match_id'];

// Create HTML Row of Event
    echo "<div class=\"units-row unit-90 centered\" style=\"border-bottom: 1px solid #333;padding-top:5px; padding-bottom:5px;\">
    <div class=\"unit-100\" style=\"margin-left:0px; text-align:center; font-size:90%; margin-bottom: 5px; \">
        <div class=\"unit-50\" style=\"margin-left:0px;\">
            <div class=\"unit-60\" style=\"margin-left:0px padding-top:5px;\">
            <a href=\"football.php?matchid=$matchid\">$event->[mkt_sort_name]</a>
            </div>
            <div class=\"unit-30\">
            $watch
            </div>
        </div>
        <div class=\"unit-50\" style=\"padding-top:5px; font-size:90%;\">
            <div class=\"unit-30\">Home Win<br /><strong>$homefodds</strong><br />$homebet</div>
            <div class=\"unit-30\">Draw<br /><strong>$drawfodds</strong><br />$awaybet</div>
            <div class=\"unit-30\">Away<br /><strong>$awayfodds</strong><br />$awaybet</div>
        </div>   
    </div>
</div>";
    }

//print $team->attributes()->{'short_name'} . ' vs ' . PHP_EOL;
//}
}
?>

Now what I'm trying to do is display ALL data based on a certain ev_id

Each Mkt element contains a name attribute and this is the data i want displayed in a loop

At present its displaying the first 2 entries
and thats it

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
    • ¥15 onvif+openssl,vs2022编译openssl64