I am writing a backend for my website and part of what I am writing includes the management of the bands (musical) on my website. I have a script that I am in the middle of writing that controls all the featrues of adding and editing all of the information stored in the database pertaining to a band. I have 80% of it done. I am running into a problem though.
First let me explain how I am handling the html. Based on the task the script is supposed to execute (add a band, add a member to the band, edit the band information, etc) I store the appropriate html in a variable called $content. It will show the form using a call such as "print $content" and if there is an error in their form it is easy to call again.
The main problem I have run into with this is when I want to edit a band, there is a huge form with a select menu basically containing every genre of music you can imagine, and when you go to edit the band I want the current genre already selected. I know how to accomplish this rather sloppily but I guess what I need to know boils down to two questions:
1) Is there a way to nest if statements inside the value of a variable changing its value based on those statements (IE, if ($genre == "rock") { echo " selected" }
2) Is there a much better way to accomplish what i need to do rather then storing huge lengths of HTML in variables which i know eats up a lot of memory. (I want to easily be able to call and recall various different html forms within the same script)
Included is a copy of the script I am working on (bands.php unfinished and very loosely commented) and another script like it which works perfectly (users.php), along with some other scripts. If you know a better way to accomplish this it would be appreciated as I will be using methods like this all throughout my website backend. I want to do this thing right the first time, so please make me aware of any other things you might notice.