mootmail-googlegroups@yahoo.com wrote:
> Mumia W. wrote:
>> Within an echo statement, <? php-code ?> does not work. Just
>> output a variable's value:
>>
>> $event_publish_checked = ($event_publish == 1 ? 'CHECKED' : '');
>>
>> echo "<tr>
>> <td Class='navText' align='center' class=$c>$event_id</td>
>> <td class='navText' class=$c>$event_name</td>
>> <td class='navText' align='center' class=$c><INPUT TYPE=CHECKBOX
>> NAME='publish' VALUE=1 $event_publish_checked </td>
>> <td class='navText' align='center' class=$c><a
>> href='delete_event.php?event_id=$event_id'>$take_a ction</a></td></tr>";
>
> Alternatively, instead of setting a variable, you can just return the
> result of the ternary operator as follows:
>
> <?=($event_publish == 1 ? 'CHECKED' : '')?>
>
> Note the '=' rather than 'echo'.
>
I think someone just noted that you cannot use the <? ?> markers in an
ECHO statement. Knowing that, this example is, sorry if I bring this
quite rudely, useless.
Besides, I think it's not smart to teach this method to someone who just
started using PHP. Using plain style 'if' statements is a way better
method to start learning how to program.
So again, I think the OP should close the echo statement, start a new
line, place the IF statement there, and then continue echo-ing whatever
he wants. The ternary operator (i didn't know they call them that way)
is something a starting programmer should learn if the time is right. I
don't think that's now for OP.
Dennis
(OP = Original Poster)