Basically looking for the best way to handle a situation like the following: I am coding a small website that for the most part really has no needs for a database unless I want to put that time in so I can make a simple CMS. I have about thirty frequently asked questions to put up on the site, and I want to reference them by id. What is the most correct solution in terms of how this should be coded? A. Make a database table and list the FAQ answers each having a unique id (already said I dont feel a need for a db for this site, but this is a possible solution). B. Just make a script that holds all the answers and use something like a switch statment on the id variable to pull the right answer. My thought is by the time I get done setting up a new db and coding the stuff for that, I am just as good using the switch statement or similar. I am interested in what is the best and most correct way in terms of speed and proper coding. Thanks!
Both those ways would work, I'd use the database - makes it easier to add answers and doesn't mean as much code as a switch statement etc. Probably not the most efficient thing to use for something of this small size though. Better than switch would probably be an array: $answers = array( '1' => 'Answer 1', '2' => 'Answer 2' ); PHP: And use foreach to get each one.
Just the kind of answer I was looking for, thank you. also just found out that client might want some customizable features in the future, so I think we just got our database anyways, I appreciate the feedback.
Any decent hosting company will provide you with the database and they're so easy to use I'd avoid the text file automatically.