php echo within an echo for a checkbox
checkbox, echo, html, input, php
Solution
echo"<input type='checkbox' name='PLJan' {if (isset($_POST['PLJan'])) print 'value='checked''} $row->PLJan /> January ";
should be
echo"<input type='checkbox' name='PLJan'";
if (isset($_POST['PLJan'])) { echo " value='checked'"; }
echo $row->PLJan . "/> January ";
Problem
I'm trying to use checkboxes to display and update records in a MySQL database. I want to change the value of the checkbox based on whether it's checked or unchecked. But I'm getting this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Here's the line of code that's throwing the error: `echo"<input type='checkbox' name='PLJan' {if (isset($_POST['PLJan'])) print 'value='checked''} $row->PLJan /> January ";` Is there a better way for me to do this so that saving it will update the database with 'checked' if the box is checked, and a blank if the box is unchecked? Thanks in advance for the halps.