Problem with Sticky Form Syntax

Ugh! I have a PHP echo statement from hell?! :rolleyes:

I am trying to make the following Radio Buttons “sticky” but can’t get the echo syntax figured out…


// Display Friend-Requests.
echo "<li>
		<a href='/account/profile.php?user=$username&tab=about-me'>
			$username<br />
			<img src='/uploads/" . $photoName . "' width='80' alt='Thumbnail of ' . $username />
		</a>
		<fieldset id='friendRequestDecision'>
			<input id='" . $requestorID . "_1' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='0' checked='checked' />
			<label for='" . $requestorID . "_1'>Decide Later</label>
			<input id='" . $requestorID . "_2' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='1' />
			<label for='" . $requestorID . "_2'>Accept</label>
			<input id='" . $requestorID . "_3' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='2' />
			<label for='" . $requestorID . "_3'>Decline</label>
		</fieldset>
	</li>\
";

I am trying to get this new code to work…


// Display Friend-Requests.
echo "<li>
		<a href='/account/profile.php?user=$username&tab=about-me'>
			$username<br />
			<img src='/uploads/" . $photoName . "' width='80' alt='Thumbnail of ' . $username />
		</a>
		<fieldset id='friendRequestDecision'>
			<input id='" . $requestorID . "_1' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='0' "
			. (isset($friendRequestDecision[$requestorID]]) && $friendRequestDecision[$requestorID] == '0') ? "checked='checked'" : "") . " />
			<label for='" . $requestorID . "_1'>Decide Later</label>

			<input id='" . $requestorID . "_2' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='1' />
			<label for='" . $requestorID . "_2'>Accept</label>

			<input id='" . $requestorID . "_3' name='friendRequestDecision[" . $requestorID . "]' type='radio' value='2' />
			<label for='" . $requestorID . "_3'>Decline</label>
		</fieldset>
	</li>\
";

Could someone please help me figure this out?

Thanks,

Debbie

What is the output of $friendRequestDecision and $requestorID as it may be that the array index doesn’t exist, please use the below code before your echo statement which will help us to help you.

echo '<pre>';
print_r($friendRequestDecision);
echo '</pre>';
echo $requestorID;

I"m guessing this is inside a FOREACH on $requestorID, and you’ve extracted the values for $_POST[‘friendRequestDecision’] into $friendRequestDecision.

Assuming those two things, the code looks mostly good… you’ve got some syntax issues up in your image.
Might want to not line break right before the piece you’re about to enter, but that shouldnt cause an issue.