j.g. Posted June 26, 2007 Share Posted June 26, 2007 Hello List! I'm very new to php and am working on a form that is used by multiple pages of the same sight; however, for one of our pages, I don't want two of the fields to display if the user selects it. So, if the id=2, then don't show these two fields (or if id != 2, show them, as I'm actually coding it)... What I've tried to do is put an 'if' statement around my two <tr>'s for the two rows I do not want displayed (if the id does not = 2, then show them...): <h2> <?= htmlentities($current->getTitle(), ENT_QUOTES); ?> </h2> <form action='<?= $PHP_SELF; ?>' method='post' enctype='multipart/form-data'> <input type='hidden' name='id' value='<?= $current->getId(); ?>' /> <input type='hidden' name='parent' value='<?= htmlentities($parent_id, ENT_QUOTES); ?>' /> <table border="0" class='thin_table'> <tr> <td class='normal' valign='top'> Award </td> <td class='normal' valign='top'> <input type='text' maxlength='200' name='title' size='60' value='<?= htmlentities($current->getTitle(), ENT_QUOTES); ?>' title='Title'> </td> </tr> <tr> <td class='normal' valign='top'> Description </td> <td class='normal' valign='top'> <textarea name='data' rows='8' cols='60' title='News'><?= htmlentities($current->getData(), ENT_QUOTES); ?></textarea> </td> </tr> <? if ($current->getId() != 2) { <tr> <td class='normal' valign='top'> Sort Order </td> <td class='normal' valign='top'> <?= simple_sort_order_select('sortorder', $current->getSortOrder(), 25); > </td> </tr> <tr> <td class='normal' valign='top'> Visible </td> <td class='normal' valign='top'> <?= true_false_checkbox('visible', ($current->getVisible() == 1)); > </td> </tr> } ?> <tr> <td class='normal' valign='top' align='center' colspan='2'> <input type='button' value='Return To Listing' onClick="window.location='/admin/awards.php';"> <input type='submit' name='save' value='Save'> </td> </tr> </table> </form> But, when I do this and click on the link to this page, I'm getting a Parse error: "Parse error: syntax error, unexpected '<' in /award_edit.php on line 82" -- Line 82 is the first line after my opening bracket after the if statement, so the bolded <tr> above... Any thoughts or ideas on how I can go about fixing this would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 <?php if ($current->getId() != 2) { ?> <tr> <td class='normal' valign='top'> Sort Order </td> <td class='normal' valign='top'> <?php= simple_sort_order_select('sortorder', $current->getSortOrder(), 25); ?> </td> </tr> <tr> <td class='normal' valign='top'> Visible </td> <td class='normal' valign='top'> <?php= true_false_checkbox('visible', ($current->getVisible() == 1)); ?> </td> </tr> <?php } ?> PS: If you use the proper <?php tags and place your code within [ code] [/ code] tags when posting you'll get syntx highlighting... much easier to read. Quote Link to comment Share on other sites More sharing options...
j.g. Posted June 26, 2007 Author Share Posted June 26, 2007 Thank you VERY much for the reply and the help!! That did it - just had to spread out my php tags... And, I apologize for the formatting of my posting...I realized I forgot to use the code tags after I had posted. Thanks again! -j.g. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.