PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
My goal is here is to simplify. There are two sections to a website, "news" and "events". I have "view.php" which I want to use to view both of them. When you are at view.php, the URL would be "view.php?nid=XX" OR "view.php?eid=XX".
While I know my code below is not 100% funcitional, is using this method a good idea? A bad habit to get into?
psurrena wrote:My goal is here is to simplify. There are two sections to a website, "news" and "events". I have "view.php" which I want to use to view both of them. When you are at view.php, the URL would be "view.php?nid=XX" OR "view.php?eid=XX".
While I know my code below is not 100% funcitional, is using this method a good idea? A bad habit to get into?
First I think encoding information into both the key and the value will be less flexible in the long run. There are places where you can do it, but in general use unique keys for each value you want.
The convention many web developers are moving towards is to specify the "controller" and "action" needed for page building. These map onto a class name and method name so you can follow the Front Controller pattern to solve the problem. In your case there could be "news" and "events" controllers and the actoin is the ID, or you would have an article viewer where "news" and "events" were the actions. WIth clean URLs that might look like http://www.mysite.com/article/news/XX/ or just http://www.mysite.com/news/XX/