blastbb
08-09-2009, 08:00 PM
I have problem with simple if function. I can't get it to work although I tried everything, and I really don't know what is problem.
<?php
$my_field_id = get_option('my_field_id');
$broj = 1;
function my_field_callback() { ?>
<input name="my_field_id" type="checkbox" value="1"
<?php
if ($my_field_id == $broj)
{
print('checked="checked"');
} ?>
/>
<?php } ?>
So get_option is WordPress function (http://codex.wordpress.org/Function_Reference/get_option) and it gets value correctly. If I echo $my_field_id I get correct values, either 0 or 1. This if should check if value is one and in that case it should print that checkbox is checked and if it is 0, it should print.
Problem is that no matter what value is, "checked" is always printed. What I'm doing wrong?
Thanks in advance
<?php
$my_field_id = get_option('my_field_id');
$broj = 1;
function my_field_callback() { ?>
<input name="my_field_id" type="checkbox" value="1"
<?php
if ($my_field_id == $broj)
{
print('checked="checked"');
} ?>
/>
<?php } ?>
So get_option is WordPress function (http://codex.wordpress.org/Function_Reference/get_option) and it gets value correctly. If I echo $my_field_id I get correct values, either 0 or 1. This if should check if value is one and in that case it should print that checkbox is checked and if it is 0, it should print.
Problem is that no matter what value is, "checked" is always printed. What I'm doing wrong?
Thanks in advance