Conditional for UL LI

I am trying to make a conditional to only show the Div and contents inside the div/ul if the first input “Features01” has some input. Any help is appreciated! Thank you!

[php]<?php if (isset($_POST['Features01'])){echo "

Features

  • $Features01
  • ";}?>
    <?php if (isset($_POST['Features02'])){echo "
  • $Features02
  • ";}?>
    <?php if (isset($_POST['Features03'])){echo "
  • $Features03
  • ";}?>
    <?php if (isset($_POST['Features04'])){echo "
  • $Features04
  • ";}?>
    <?php if (isset($_POST['Features05'])){echo "
  • $Features05
  • ";}?>


[/php]

It’s good that you’re checking if the variable is set before you use it. But, you’re not using $_POST when you echo out the $Features01 variable. To test if it’s blank, you can use the empty function:

[php]if(empty($some_variable) == false) {
echo $some_variable;
}[/php]

So, to combine it with your isset and use of $_POST, the Features01 line would look something like this:

[php]<?php if (isset($_POST['Features01']) && empty($_POST['features']) == false){echo "

Features

  • ", $_POST['Features01'], "
  • ";}?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service