0

我有一个包含以下代码的表单:

<?php    
echo '<form action="nba-agent-process-bet.php" method="post">';  
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>';       
for($i=0 ; $i<10;){  
$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;   
$AHomeRotNum = $event->participants->participant[1];   
$AVisitingRotNum = $event->participants->participant[0];  
$AHomeParticipantName = $event->participants->participant[1];  
$AVisitingParticipantName = $event->participants->participant[0];  
$MoneyLine = $event->periods->period[0]->moneyline;   
$AwayLine[] = $Spread->spread_visiting;   
$HomeLine[] = $Spread->spread_home;  
$UnderAdjust[] = $TotalPoints->under_adjust;   
$OverAdjust[] = $TotalPoints->over_adjust;  
$ATotalPoints[] = $TotalPoints->total_points;  
$VisitingRotNum[] = $AVisitingRotNum->rotnum;  
$HomeRotNum[] = $AHomeRotNum->rotnum;  
$VisitingParticipantName[] = $AVisitingParticipantName->participant_name;  
$HomeParticipantName[] = $AHomeParticipantName->participant_name;  
$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>$VisitingRotNum[$i]</td></tr><tr><td>$HomeRotNum[$i]</td></tr></table></td><td><table><tr><td>$VisitingParticipantName[$i]</td></tr><tr><td>$HomeParticipantName[$i]</td></tr></table></td><td><table><tr><td><input type='checkbox' name='AwayMoneyLine' value='$AwayMoneyLine[$i];$HomeParticipantName[$i]'/> $AwayMoneyLine[$i]</td></tr><tr><td><input type='checkbox' name='HomeMoneyLine' value='$HomeMoneyLine[$i];$AwayParticipantName[$i]'/>$HomeMoneyLine[$i]</td></tr></table></td><td><table><tr><td><input type='checkbox' name='$AwaySpreadAdjust[$i]' value='$AwayLine[$i]'/> $AwayLine[$i] ($AwaySpreadAdjust[$i])</td></tr><tr><td><input type='checkbox' name='$HomeSpreadAdjust[$i]' value='$HomeLine[$i]'/> $HomeLine[$i] ($HomeSpreadAdjust[$i])</td></tr></table></td><td><table><tr><td><input type='checkbox' name='AwayTotalPoints' value='$TotalPoints[$i]'/> Over $ATotalPoints[$i]</td></tr><tr><td><input type='checkbox' name='HomeTotalPoints' value='$ATotalPoints[$i]'/> 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>';  
?>  

基本上,for 循环贯穿我的 xml 项目。foreach 循环将值分配给数组。数组打印在表格中,循环中的每个 $i 代表表格中的一行。当一个复选框被选中并提交时,我想通过复选框中的值传递所选 $i 的多个数组。我在表单操作中有以下代码:

例如,我尝试传递 $HomeMoneyLine 并回显该值,但没有运气。任何帮助将不胜感激!

<?php session_start(); ?>  
<?php  
if($_POST['AwayMoneyLine'] == $_POST['$AwayMoneyLine']){  
     $bet_type="Moneyline";  
     $HomeTeam=$_POST['$HomeMoneyLine[$i]'];  
     echo $HomeTeam;  
}   
else {   
header("Location: http://www.mainurl.com/");   
}   
?>  
4

1 回答 1

1
if($_POST['AwayMoneyLine'] == $_POST['$AwayMoneyLine']){  
                                     ^--            ^--

这些可能不是您要查找的引号,除非您在表单中使用字面量、、、$A...w作为字段名称。

于 2012-10-31T04:25:24.320 回答