Conditional display of an item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharmilah
    New Member
    • Jun 2007
    • 20

    Conditional display of an item

    Hi All

    Thanks for the replies to my previous questions. I have some code down there to enable editing of a field called 'Usr_Surname' if the value of the variable 'authorise' is one . If the variable authorise is any other value than one I want to display the field 'Usr_Surname' without allowing users to edit it. The code is not working. I need some help. Thanks

    [PHP]</tr>
    <tr>
    <td class="hr"><? echo htmlspecialchar s("Surname")."& nbsp;" ?></td>
    <td class="dr"><? if ($authorise=='1 ') ?><textarea cols="35" rows="4" name="Usr_Surna me" maxlength="100" ><? echo str_replace('"' , '&quot;', trim($row["Usr_Surnam e"])) ?></textarea>
    <? else echo trim($row["Usr_Surnam e"]) ?></td>
    </tr>
    <tr>[/PHP]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, sharmilah.

    Originally posted by sharmilah
    If the variable authorise is any other value than one I want to display the field 'Usr_Surname' without allowing users to edit it. The code is not working. I need some help.
    Try using a PHP echo statement:

    [code=php]
    <?php
    if ($authorise=='1 ')
    echo '<textarea cols="35" rows="4" name="Usr_Surna me" maxlength="100" >' . htmlspecialchar s(trim($row["Usr_Surnam e"])) . '</textarea>';
    ?>
    [/code]

    If this doesn't work, I'd check to make sure $authorise actually has a value (did you mean $authorize?).

    PS. As a sidenote:
    [code=php]
    <? echo htmlspecialchar s("Surname")."& nbsp;" ?>

    // Wouldn't this do the same thing?
    Surname&nbsp;
    [/code]

    Comment

    Working...