0

my code starts with multiple php arrays with XML data being passed through multiple checkboxes in the following way($i cycles through items in XML doc, values pass specific data in row i that is selected):

$MoneyLine = $event->periods->period[0]->moneyline; //background info
$AwayMoneyLine[] = $MoneyLine->moneyline_visiting;  //background info
<input type='checkbox' name='AwayMoneyLine'   value='$Date[$i];$AwayRotNum[$i];$AwayParticipantName[$i];$ATotalPoints[$i]'/>  

On my next page, I pass the variables in the following manner, but they are not resulting on the next page.:

if(isset($_POST['AwayMoneyLine'])){  
foreach($_POST['AwayMoneyLine'] as $value) {   
$d = explode(';',$value);    
echo '<input type="hidden" name="hidden[]" value="$d[0];$d[1];$d[2];$d[3];$d[4]">';  

Here is how I'm attempting to get the data on the next page. Any suggestions on how I can pass the variables through to this page? On the form (also on var_dump of $d), I get $d[0], $d[1], etc. Any help is greatly appreciated!:

foreach($_POST['hidden'] as $value) {  
$f = explode(';',$value);  
echo 'Here is your following bet:';  
echo '<table cellpadding="0" cellspacing="0" border="1" bordercolor="#585858" width=100%>';  
     echo "<tr><td>$e[0]</td><td>$f[0]</td><td>$f[1]</td><td>$f[2]</td><td>$f[3]</td><td>$f[4]</td></tr>";  
}  
echo '</table>';
4
  • 1
    Why dont you put them in the $_SESSION[]? Commented Nov 1, 2012 at 5:27
  • Use double quote if you want php to replace your variables with values assigned to this variables in sting, e.g. echo "$myvar" Commented Nov 1, 2012 at 5:30
  • @case1352 I'm working on a session fix, but I was wondering if it was possible using the example I had. It's definitely my next option though! Commented Nov 1, 2012 at 5:41
  • @Nemoden I'm not sure I understand what you're suggesting to double quote. Could you be more specific? Commented Nov 1, 2012 at 5:43

2 Answers 2

2

Change the code to:

echo "<input type=\"hidden\" name=\"hidden[]\" value=\"$d[0];$d[1];$d[2];$d[3];$d[4]\">";  

$d[0];$d[1];$d[2];$d[3];$d[4] will not be printed as you put inside single quote. You should use double quote and escape attributes like type=\"hidden\", name=\"hidden[]\", etc.,

eg:

<?php

$name = 'foo';
echo "$name";
echo '<br />';
echo '$name';
?>

Output:

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

1 Comment

thanks for your help, I really need to be more careful with my single and double quotes!
0
use $serial=serialize($array);
echo "<input type=\"hidden\" name=\"hiddenfield\" value=\"<?php echo$serial; ?>">"; 

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.