I have some code below that outputs a bullet list. This will create about 6 different bullet points. However im stuck on how i can create a session varible for each bullet point, so everytime a user clicks on the bullet point (or on the 'submit' button) this will create a session varible with the value = $test. Session_start() has been added before this code
.............
//This will output a bullet point list
echo "<form action='Cleanser_step3.php' name='form2' method='POST'>";
for ($test=1; $test<=$column1; $test++){
echo "<label>";
echo "<input type='radio' name='Col$test' value=$test" ;
if (isset($fields['Col$test']) == '$test') echo 'checked';
echo ">";
echo "Column ".$test;
echo "</label>";
echo "<br>";
}
echo "<input type='submit' align='right' value='Next >>'>";
$_SESSION['$DimOther'] = $DimOther;
echo "</form>";
}
................
Bullet Points and Session Varibles
Moderator: General Moderators
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Bullet Points and Session Varibles
Not totally clear about what you're doing to be honest, but I wonder if you have made a mistake in your array indices:
What I'm getting at is the difference between no quotes, single quotes and double quotes, see here. Furthermore, and you'd need to look into it, I believe that (though it is bad practice) if you provide an unquoted array key, and no constant of that name has been defined, PHP will effectively quote the key for you. Which might complicate things a bit, I'm sure you can investigate through trial and improvement 
Code: Select all
// Should this:
$fields['Col$test']
// Be written like this:
$fields[ "Col$test" ]
// Or:
$fields[ 'Col'. $test ]
// And this:
$_SESSION['$DimOther'] = $DimOther;
// Be altered as follows:
$_SESSION[ $DimOther ] = $DimOther;