If statement on $_REQUEST then do something.

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 17, 2020   (RSS)

By daniel - January 17, 2020

Hi Zick,

I think this should accomplish your goal:

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" id="floorplanResults">
    <select name="floor_plan_match" onchange="$('#floorplanResults').submit();">
        <option value="">Floor Plans</option>
    <?php foreach ($homes_for_saleCatArray as $value => $label): ?>
        <option value="<?php echo $value; ?>" <?php selectedIf($value, @$_REQUEST['floor_plan']) ?>><?php echo $label; ?></option>
    <?php endforeach ?>
        <?php if(!empty($_REQUEST['floor_plan'])): ?><option value="">All Floor Plans</option><?php endif; ?>
    </select>
  </form>

This will add the last option "All Floor Plans" to the dropdown if the $_REQUEST['floor_plan'] has any non-empty value in it.

Let me know if you have any further questions!

Thanks,

Daniel
PHP Programmer
interactivetools.com