Hello all,
Iam doing a footy tipping site, a page I am doing atm is to specify who won game and by what margin.
I can get the page to load into $_POST the winner_id, but the margin is getting me.
I am using a text input which looks like this:
echo ('<td><input type="text" name="margin[]'.$i.'"></td>');
On the processing page it returns this array:
Array ( [w2] => 1 [margin] => Array ( [0] => 12 [1] => 35 [2] => 44 [3] => 52 [4] => 15 ) [w3] => 10 [w4] => 3 [w5] => 2 [w6] => 2 [update] => Submit )
The bit in bold, I have identified as the array for the margin.
What I want to know is how do I get it out of the array and into variables?
My processing page looks like this:
foreach ( $_POST as $key => $value )
{
// get first char. of $key, if it's 'w', then we've got tips
if ( substr( $key, 0, 1) == 'w' )
{
//to test outputs from array
print_r($_POST) ;
$margin = $_POST['margin'];
//$margin = ;
$winner_id = $value;
echo 'winner:'.$winner_id.' margin '.$margin.'<br />';
Any help would be muchly appreciated.
Thank you,
Matt