0

I have a form with the following code:

<?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>';  
?>  

Basically, the for loop runs through my xml items. The foreach loops assign values to the arrays. The arrays are printed in a table, each $i in the loop representing a row in the table. When a checkbox is selected and submitted, I would like to pass multiple arrays for the selected $i through values in the checkboxes. I have the following code in the form action:

For example, I try to pass $HomeMoneyLine and echo the value, but have had no luck. Any help would be greatly appreciated!

<?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/");   
}   
?>  
6
  • 1
    general tip: if you're going to be talking about a particular form element, it'd be helpful if you didn't bury that form element 6 miles to the right in the middle of a long text string. Commented Oct 31, 2012 at 4:24
  • $HomeMoneyLine[$i] is an array right? Try printing $HomeMoneyLine[0]; Commented Oct 31, 2012 at 4:26
  • @TomAngeloClemente Yes it is an array. Nothing printed, and NULL when I used var_dump Commented Oct 31, 2012 at 4:43
  • $var = $_POST['HomeMoneyLine']; print the $var then see what happens Commented Oct 31, 2012 at 4:53
  • @TomAngeloClemente thanks for your help, $var does display the HomeMoneyLine. However, I am trying to pass multiple values in the checkboxes such as: <td><input type='checkbox' name='AwayMoneyLine' value='$AwayMoneyLine[$i];$HomeParticipantName[$i];$HomeMoneyLine[$i]'/> $AwayMoneyLine[$i]</td> Commented Oct 31, 2012 at 5:03

1 Answer 1

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

these are probably not the quotes you are looking for, unless you've used literal $, A, w, etc... as the field's name in your form.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.