Toggling between a normal site page and a forum entry.
Posted: Fri Oct 01, 2004 11:15 pm
Hello,
Simply for the learning experience, and the flexibility, I have decided to design my next personal website from the ground up, starting with a blank PHP file, so to speak.
The website will have a message board, and of course, normal web site features like things I have done and other such things.
I have decided to adopt the pretty much standard 3 table design:
1. Directories
2. Topics
3. Comments (Or replies).
When I have a normal web page that I want to select from the database, I would simply call the normal function to display a topic in an ordinary forum... or not.
Obviously, the data needs to be formatted differently for an article on my website than a normal discussion topic.
So, how would you go about telling the function how to display the data?
I've thought of several ways:
1. Declare a constant at the beginning of the script, determining whether the page is a topic or an article
2. Send a variable along with the function to display a topic/article, for instance, $render_as_article = TRUE, to determine how to format the data returned from the database.
3. Simply use the functions to call the query, return the $row = mysql_fetch_array($query);, and then I have an array of the data, and can format it however I choose. This method seems a bit to clunky to me, and would probably require me copying the same script over and over again or creating yet another set of functions.
Any thoughts?
- Monkey
Simply for the learning experience, and the flexibility, I have decided to design my next personal website from the ground up, starting with a blank PHP file, so to speak.
The website will have a message board, and of course, normal web site features like things I have done and other such things.
I have decided to adopt the pretty much standard 3 table design:
1. Directories
2. Topics
3. Comments (Or replies).
When I have a normal web page that I want to select from the database, I would simply call the normal function to display a topic in an ordinary forum... or not.
Obviously, the data needs to be formatted differently for an article on my website than a normal discussion topic.
So, how would you go about telling the function how to display the data?
I've thought of several ways:
1. Declare a constant at the beginning of the script, determining whether the page is a topic or an article
2. Send a variable along with the function to display a topic/article, for instance, $render_as_article = TRUE, to determine how to format the data returned from the database.
3. Simply use the functions to call the query, return the $row = mysql_fetch_array($query);, and then I have an array of the data, and can format it however I choose. This method seems a bit to clunky to me, and would probably require me copying the same script over and over again or creating yet another set of functions.
Any thoughts?
- Monkey