I'm echoing the HTML which makes a checkbox, how can I make it checked based on an IF inside the echo itself? It works fine if I code it HTML with a nested php line. This works:
<input name="ipnetcheck" type="checkbox"
onkeypress="return handleEnter(this, event)" id="ipnetcheck"
value="1" <?php if ($ipnetcheck==1) echo "checked";?> >
Buuuut I need this to work based on the conditional test which precedes this echo:
echo "<label>IP<input type='checkbox' name='ipnetcheck' value='1' . if ($ipnetcheck==1) {checked}></label>";
This gets me all kinds of no bueno. It's a dymanic form and based on how you select check boxes, text fields appear. This works, too. I know this sounds like client-side stuff here but wait a second. Before I echo the HTML fields I'm querying SQL, so I have my vars. Then, when I echo the checkboxes I want them to be checked if the var returns 1 (I store checked boxes in SQL as a 1, unchecked as 0).
I'm stuck because I don't get doing an IF statement inside an echo.
Clown the code if you want, it's midnight and I'm throwing poop at the wall to see what sticks. HELP!!!