[thelist] Logic headache

Ray Hill lists at prydain.com
Mon Nov 11 11:16:01 CST 2002


> I'm building a select list in PHP, to exclude certain
> directories from a search
>
> The structure is like this:
> <select name="exclude">
>   <option value="">All levels</option>
>   <option value="/lv2/|/lv3/|/lv4/">Level 1</option>
>   <option value="/lv1/|/lv3/|/lv4/">Level 2</option>
>   <option value="/lv1/|/lv2/|/lv4/">Level 3</option>
>   <option value="/lv1/|/lv2/|/lv3/">Level 4</option>
> </select>

Wait.  You have a form field called "exclude" and the value of it is the
list of values that are *not* excluded?  I think that's where your logic is
hitting a wall.  It seems to me that it would be much simpler and more
intuitive to have the value of this form fields be just the value that is
being excluded.  Example:

<select name="exclude">
  <option value="">All levels</option>
  <option value="/lv1/">Level 1</option>
  <option value="/lv2/">Level 2</option>
  <option value="/lv3/">Level 3</option>
  <option value="/lv4/">Level 4</option>
</select>

Then, on the php page that processes it, you just exclude that value.
Possibly by starting with an array of all possible values, removing the
excluded ones, then looping through the array.  Or possibly by looping
through all possible values and wrapping the functionality within an

if (value != $exclude) {}

statement.


--ray





More information about the thelist mailing list