1

I have a bit of an easy question which i cant seem to figure out.

I have the following line

$output .= '    <input name="_'.$row->key.'" style="height: 10px; margin: 0;" type="checkbox" id="'.$row->key.'" />&nbsp;&nbsp;<span style="font-size: 9px; text-transform: lowercase;">'.$row->name.'</span>';

and i need to add the following to it, but they are different format

trim(set_radio("allwork", "1")) == 'checked="checked"' ? true : false

If i do '. and .' before and after the trim section and insert it, it throws errors

Cheers,

2
  • Consider putting your CSS in a stylesheet instead of inline. Commented Dec 20, 2010 at 1:06
  • The ` ? true : false` part is redundant. But as for your problem, you might want to put such constructs into utility functions. Commented Dec 20, 2010 at 1:06

2 Answers 2

2

For in-line conditions you should wrap them in parenthesis then you can concatenate them. For example:

echo "Hello, " . ($a == $b ? "world." : "universe.");

EDIT corrected syntax, my apologies to those taking "b" literally.

Sign up to request clarification or add additional context in comments.

1 Comment

This will throw an error because b is not a proper php variable. Unless it' a predefined constants which should be capitalized per php documentary.
0

@Chris: Try --

$output .= '    <input name="_'.$row->key.'" style="height: 10px; margin: 0;" type="checkbox" id="'.$row->key.'"';
if (trim(set_radio("allwork", "1")) == 'checked="checked"') { $output .= ' checked="checked"'; }
$output .= ' />&nbsp;&nbsp;<span style="font-size: 9px; text-transform: lowercase;">'.$row->name.'</span>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.