Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple checkbox question

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Hi

I am trying to get the $array_number variable into the input box but i cannot manage it i keep getting this from the echo statement

$key => $array_number

instead of getting

$key => 0
$key => 1

etc

My question is really can you do this value="$array_number"


**************** Code *************************

// Get the array number
$array_number = $grind_number - 1;

echo'<p class = "confirmation"><input type="checkbox" name="remove[]" value="$array_number"/>&nbsp;Remove</p>';

if (isset($_POST['submit']))
{
foreach($_POST['remove'] as $key=> $data)
{
echo $key.'=>'. $data.'<br>';
}



}
 
The difficulty lies in the fact that single quoted strings are not parsed for variable substitution. Since you single quote your expression $array_number will be treated as a literal, just like any other text.
You can get out of your predicament by interrupting the quoted string and concatenating the variable.
Code:
echo '<p class = "confirmation"><input type="checkbox" name="remove[]" value="[COLOR=red]'.[/color]$array_number[COLOR=red].'[/color]"/>&nbsp;Remove</p>';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top