Switching database values with PHP

I have a website that displays pages based on scientific names stored in a database table. For example, if the database includes the value ‘bison’, then it will display a page at MySite/bison.

The problem is that there are a few scientific names that are duplicates. For example, Phyllanthus is the name of both a genus of birds and a genus of plants. So if I navigate to MySite/phyllanthus, it displays the bird information by default.

I would like to include a little box near the top of the page that asks “Were you looking for information on the PLANT genus?” People could then click on a link, and the page would display information on the plant - without changing the URL.

I think the key to accomplishing this is the database’s parent-child relationship. Let’s say the bird Phyllanthus’ parent is ‘Uno’ and the plant Phyllanthus’ parent is ‘Dos.’ I have a script that traces parents and grandparents to the top of the food chain, ultimately recognizing a scientific name as a bird, mammal, plant, etc.

So here’s my question: Is there a way to enable visitors to change a database value? Specifically, how can they click a button or link that changes the parent from ‘Uno’ to ‘Dos’, changing the page content from information about a bird to information about a plant?

Thanks.

You could use the same method that wikipedia use so using your example

MySite/phyllanthus_(bird) would bring up the bird “version”

MySite/phyllanthus_(plant) would bring up the plant “version”

and MySite/phyllanthus would bring up a “disambiguation” page with links to the two “versions”, essentially asking you which “version” you intend

1 Like

OK, that might be the simplest solution. Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.