Re: problem with dynamic populating checkbox



calmsqurill@xxxxxxxxx wrote:
HI,

First of all im vry new to PHP, i like to retrieve a value from DB,
accordingly i like to display the checkbox, either checked or not.


Now im able to retrieve the value from DB, i can show even show the
checkbox, but i cant make it checked????


Can anyone help, plzzzzzzz!!!


[cut]

Hi

Check the output of your code. As you can see it places if($event_publish==1){'CHECKED';}?> straight into your code. This is because it is misplaced.


Solution:
Stop your string after 'publish'. Then start a new line with the if statement, remove the ?>, and start a new string again:

<td class='navText'
align='center' class=$c><input type='checkbox'
name='publish' ";

if($event_publish==1){'CHECKED';}

echo "</td>... etc.

Besides, CHECKED should be checked="checked" to comply with new xhtml rules (Safari on Mac relies on this :-s)

Dennis
.



Relevant Pages