XML PHP表输出错误

XML PHP表输出错误,php,xml,for-loop,html-table,xmlnode,Php,Xml,For Loop,Html Table,Xmlnode,下面是我的代码的一部分,我使用PHP将XML数据提取到一个表中。问题是,我表格中的第一行是空的(除了那些永远不会离开的复选框)。任何帮助都将不胜感激 <!-- language-all: lang-php --> <?php $AwayMoneyLine[] = (string)$xml2->moneyline_visiting; $HomeMoneyLine[] = (string)$xml2->moneyline_home;

下面是我的代码的一部分,我使用PHP将XML数据提取到一个表中。问题是,我表格中的第一行是空的(除了那些永远不会离开的复选框)。任何帮助都将不胜感激

<!-- language-all: lang-php -->
<?php  
    $AwayMoneyLine[] = (string)$xml2->moneyline_visiting;  
    $HomeMoneyLine[] = (string)$xml2->moneyline_home;  
    $AwaySpreadAdjust[] = (string)$xml2->spread_adjust_visiting;   
    $HomeSpreadAdjust[] = (string)$xml2->spread_adjust_home;  
    $AwayLine[] = (string)$xml2->spread_visiting;  
    $HomeLine[] = (string)$xml2->home_visiting;  
    $UnderAdjust[] = (string)$xml2->under_adjust;  
    $OverAdjust[] = (string)$xml2->over_adjust;  
    $ATotalPoints[] = (string)$xml2->total_points;  
    $Date[] = (string)$xml->Date;  
    $AwayTeam[] = (string)$xml->AwayTeam;  
    $HomeTeam[] = (string)$xml->HomeTeam;  
    $AwayRotation[] = (string)$xml->AwayRotation;  
    $HomeRotation[] = (string)$xml->HomeRotation;  
    $Total = (string)$xml->Total;  
    $OverPrice[] = (string)$xml->OverPrice;  
    $UnderPrice[] = (string)$xml->UnderPrice;  
    $Line[] = (string)$xml->Line;  
    $AwayTeamPrice[] = (string)$xml->AwayTeamPrice;  
    $HomeTeamPrice[] = (string)$xml->HomeTeamPrice;  
    $AwayTeamMoneyLine = (string)$xml->AwayTeamMoneyLine;  
    $HomeTeamMoneyLine = (string)$xml->HomeTeamMoneyLine;  
    $Title = (string)$xml->Title;  
    echo '<table cellpadding="0" cellspacing="0" border="1" bordercolor="#585858" width=100%>';      
    echo '<tr>';  
    echo '<th>Date</th>';  
    echo '<th>#</th>';   
    echo '<th>Team</th>';  
    echo '<th>Money</th>';  
    echo '<th>Spread</th>';  
    echo '<th>Total</th>';  
    echo '</tr>';  
    $count = count($Game);      
    for($i=0; $i<20;){  
    $AwayTeamSpread = " ";    
    $HomeTeamSpread = " ";  
    foreach ($xml->Game as $Game) {   
    $Date[] = $Game->Date; $AwayTeam[] = $Game->AwayTeam; $HomeTeam[] = $Game->HomeTeam; $AwayRotation[] = $Game->AwayRotation;  
    $HomeRotation[] = $Game->HomeRotation; $Total[] = $Game->Total; $OverPrice[] = $Game->OverPrice;  
    $UnderPrice[] = $Game->UnderPrice; $Line[] = $Game->Line; $AwayTeamPrice[] = $Game->AwayTeamPrice;  
    $HomeTeamPrice[] = $Game->HomeTeamPrice; $AwayTeamMoneyLine[] = $Game->AwayTeamMoneyLine; $HomeTeamMoneyLine[] = $Game->HomeTeamMoneyLine;  
    }  
    foreach ($xml2->events->event as $event) {  
    $Spread = $event->periods->period[0]->spread;  
    $TotalPoints = $event->periods->period[0]->total;    
    $AwayLine[] = $Spread->spread_visiting;   
    $HomeLine[] = $Spread->spread_home;  
    $UnderAdjust[] = $TotalPoints->under_adjust;   
    $OverAdjust[] = $TotalPoints->over_adjust;  
    $ATotalPoints[] = $TotalPoints->total_points;  
    $AwayMoneyLine[] = $MoneyLine->moneyline_visiting;   
    $HomeMoneyLine[] = $MoneyLine->moneyline_home;  
    $AwaySpreadAdjust[] = $Spread->spread_adjust_visiting;   
    $HomeSpreadAdjust[] = $Spread->spread_adjust_home;  
    }     
    echo '<tr>';  
    echo "<td>$Date[$i]</td><td><table><tr><td>$AwayRotation[$i]</td></tr><tr><td>$HomeRotation[$i]</td></tr></table></td><td><table><tr><td>$AwayTeam[$i]</td></tr><tr><td>$HomeTeam[$i]</td></tr></table></td><td><table><tr><td><input type='checkbox'/> $AwayTeamMoneyLine[$i]</td></tr><tr><td><input type='checkbox'/>$HomeTeamMoneyLine[$i]</td></tr></table></td><td><table><tr><td><input type='checkbox'/> $AwayLine[$i] ($AwaySpreadAdjust[$i])</td></tr><tr><td><input type='checkbox'/> $HomeLine[$i] ($HomeSpreadAdjust[$i])</td></tr></table></td><td><table><tr><td><input type='checkbox'/> Over $ATotalPoints[$i]</td></tr><tr><td><input type='checkbox'/> Under $ATotalPoints[$i]</td></tr></table></td>";  
    echo '</tr>';  
    $i++;  
}  
    echo '<tr>';  
    echo '<td colspan="3"><input type="submit" name="send" value="Submit"></td><td colspan="3"><input type="button" name="Clear" value="Clear" /></td>';  
    echo '</tr>';  
    echo ' </table>';  
    ?>

moneyline_访问;
$HomeMoneyLine[]=(字符串)$xml2->moneyline\u home;
$AwaySpreadAdjust[]=(字符串)$xml2->spread\u adjust\u访问;
$HomeSpreadAdjust[]=(字符串)$xml2->spread\u adjust\u home;
$AwayLine[]=(字符串)$xml2->spread\u访问;
$HomeLine[]=(字符串)$xml2->主页访问;
$UnderAdjust[]=(字符串)$xml2->UnderAdjust;
$OverAdjust[]=(字符串)$xml2->over_adjust;
$ATotalPoints[]=(字符串)$xml2->总分;
$Date[]=(字符串)$xml->Date;
$AwayTeam[]=(字符串)$xml->AwayTeam;
$HomeTeam[]=(字符串)$xml->HomeTeam;
$AwayRotation[]=(字符串)$xml->AwayRotation;
$HomeRotation[]=(字符串)$xml->HomeRotation;
$Total=(字符串)$xml->Total;
$OverPrice[]=(字符串)$xml->OverPrice;
$UnderPrice[]=(字符串)$xml->UnderPrice;
$Line[]=(字符串)$xml->Line;
$AwayTeamPrice[]=(字符串)$xml->AwayTeamPrice;
$HomeTeamPrice[]=(字符串)$xml->HomeTeamPrice;
$AwayTeamMoneyLine=(字符串)$xml->AwayTeamMoneyLine;
$HomeTeamMoneyLine=(字符串)$xml->HomeTeamMoneyLine;
$Title=(字符串)$xml->Title;
回声';
回声';
回音“日期”;
回音“#”;
回声“团队”;
呼应"钱",;
回声“扩散”;
回声“总计”;
回声';
$count=count($Game);
对于($i=0;$iGame作为$Game){
$Date[]=$Game->Date;$AwayTeam[]=$Game->AwayTeam;$HomeTeam[]=$Game->HomeTeam;$AwayRotation[]=$Game->AwayRotation;
$HomeRotation[]=$Game->HomeRotation;$Total[]=$Game->Total;$OverPrice[]=$Game->OverPrice;
$UnderPrice[]=$Game->UnderPrice;$Line[]=$Game->Line;$awaytemprice[]=$Game->awaytemprice;
$HomeTeamPrice[]=$Game->HomeTeamPrice;$AwayteAmmonyLine[]=$Game->AwayteAmmonyLine;$HomeTeamMoneyLine[]=$Game->HomeTeamMoneyLine;
}  
foreach($xml2->events->event as$event){
$Spread=$event->periods->period[0]->Spread;
$TotalPoints=$event->periods->period[0]->total;
$AwayLine[]=$Spread->Spread\u访问;
$HomeLine[]=$SPRIDE->SPRIDE\U home;
$UnderAdjust[]=$TotalPoints->UnderAdjust;
$OverAdjust[]=$TotalPoints->over_adjust;
$ATotalPoints[]=$TotalPoints->总分;
$AwayMoneyLine[]=$MoneyLine->MoneyLine\u访问;
$HomeMoneyLine[]=$MoneyLine->MoneyLine\u home;
$AwaySpreadAdjust[]=$Spread->Spread\u adjust;
$HomeSpreadAdjust[]=$SPRIDE->SPRIDE\u adjust\u home;
}     
回声';
echo“$Date[$i]$AwayRotation[$i]$HomeRotation[$i]$AwayTam[$i]$HomeTeam[$i]$AwayLine[$i]$AwayLine[$i]($AwaySpreadAdjust[$i])$HomeLine[$i]($HomeSpreadAdjust[$i])超过$ATotalPoints[$i]低于$ATotalPoints[$i]”;
回声';
$i++;
}  
回声';
回声';
回声';
回声';
?>

要真正理解这个问题,我们需要查看XML的内容。但是,快速修复方法应该是将for循环更改为:

for ($i = 1; $i <= 20)

用于($i=1;$i抱歉,但是错误是什么?当我打印到表中时,表的第一行对于所有值都是空的。第二行是第一组数据,即$i=0感谢临时解决方案。如果我明天提供一个屏幕截图并提供一些更详细的信息,您能提供一些更深入的信息吗?我很乐意提供帮助。尽管我知道如果你能给我更多关于foreach循环应该做什么的细节,我想如果不是for循环,那么foreach循环可能与你的问题有关。