PHP problem - if / else

stevet70

New Member
Messages
35
Reaction score
0
Points
0
currently the code in question looks like this:

HTML:
    <tr>
      <td width="140" height="30" align="left" valign="top">Interests</td>
      <td width="320" height="30" align="left" valign="top"><input type="checkbox" name="exhibitions" value="yes" <?php if ($exhibitions == 'yes') ?> checked="checked" /><?php } else { ?> /> <?php } ?>
        Exhibitions</td>
    </tr>

There's a series of check boxes on a form for updating subscription preferences. What I'd like them to do is show up as 'checked' if someone has previously opted in, or not if they haven't.

I've tried a few methods, but nothing is working so far.

Any pointers as to where this is going wrong?

The current error message is "Parse error: syntax error, unexpected T_ELSE in /home/stevetur/public_html/testarea/cms/about/subscribe_update.php on line 132"

thanks
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
<tr>
<td width="140" height="30" align="left" valign="top">Interests</td>
<td width="320" height="30" align="left" valign="top"><input type="checkbox" name="exhibitions" value="yes" <?php if ($exhibitions == 'yes') ?> checked="checked" /><?php } else { ?> /> <?php } ?>
Exhibitions</td>
</tr>

You start an if declaration there, but you never you never tell it what to do.:nuts:
 

gomarc

Member
Messages
516
Reaction score
18
Points
18
You are missing an opening bracket { after the if():

Code:
<?php if ($exhibitions == 'yes') [COLOR=Red][B]{[/B][/COLOR]?> checked="checked" />
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
I would like to add another comment, primarily for efficiency. Since the /> is repeated twice, you can remove it from the if clause:
PHP:
<?php if ($exhibitions == 'yes') { ?> checked="checked" <?php } ?>/>
 
Last edited:
Top