Hope I can explain this sufficiently. Here goes.
I have two form pages. One is basically a search page that posts the results of the search to the second page where the user uses the results, adds some of his own information and posts the entire thing to the database.
The second page is a form in which a researcher is adding a new species to the database. In order that he doesn't have to add all the phylum, subphylum, class, subclass, order, suborder....etc information everytime he wants to add a new species, I let him narrow down all these categories via the search form on the first page. And as I mentioned, the results post to this second page which fills in about the first half of this new species add form. The researcher then basically has all the hierarchy information already posted on the page and he can add the species information.
The first page has five search categories (in a sense from broad to specific). They are:
Phylum
Class
Order
Family
Genus
Now here's the catch. If someone chooses just the broad category of phylum without specifying any of the other parameters (there could be 20 classes, 20 orders, 50 families, etc in a phylum) the record that posts on the 2nd page will be the first record of that phylum in the database. Although the phylum is correct, the researcher may be looking for a different class, order, family etc.
The following code is the code I am presently using:
SELECT *
FROM fauna
WHERE phylum LIKE '%varphylum%' AND class LIKE '%varclass%' AND order like '%varord%' AND family LIKE %varfam% AND genus LIKE '%vargen%' AND ('varphylum' != '' OR 'varclass' != '' OR 'varord' != '' OR 'varfam' != '' OR 'vargen' != '')
What I need is the following. If a researcher just enters a value for phylum, class, and order I want ONLY values from the database for order and above (i.e., phylum, class and order). I don't want any of the results for anything below that. Likewise if a researcher only adds a value in the family category I want all information for family and above (even though he didn't specify phylum, class, order in the search).
I hope that is clear and I sure would appreciate any help
Thanks