This is more of a PHP design question. Basically, I’m going to have a form with a drop down menu and a submit button. I am going to have an infinite amount of drop down options; obviously, not an infinite, but there’s basically going to be a drop down menu with ALOT of options. These “options” are individual reports that I want to run.
So, the user selects from the drop down menu, for example, “Articles without approval”, which I want to tie to a function in my functions.php file that runs the SQL for this and outputs everything nicely in a table.
My problem is, how do I do this without have a huge if/else statement in my main document that that basically says “If the submit button is equal to “Articles without approval”, do this”, etc etc for every drop down option. I need something dynamic, without a bunch of if/else statements.
Am I overthinking this?
Unless you want to wrap all of your app into a framework that might be more conducive to this sort of thing, you’ll probably find it easier to call the function dynamically.
Suppose you had functions called
articlesWithoutApproval()andarticlesWithApproval(). Then, you could do something like this:Then, in
handler.php, do: