I'm in the process of writing a comment system for my blog.
Each blog page will be on a PHP document with an HTML form where the viewer can type in their name and comment in a form at the bottom.

echo "<form action='postcomment.php' method='post'>";
echo "<input type='text' name='PosterName'/>" . "<br/>";
echo "<textarea rows='7' cols='50' name='Comment'></textarea>";
echo "<input type='submit' />";
echo "</form>";

The postcomment.php file will connect to the database, but I'm having trouble when it comes to individual tables. My table names are according to the blog ID (not a variable, just the name of the page). How can I turn the blog ID into a variable on the blog entry page, and how can I pass it to the postcomment.php file so that the correct table can be accessed?

None of these individual blog pages have been created yet, so if it would be easier to use a different format, let me know.


8 Years
Discussion Span
Last Post by diafol

You shouldn't have a multiple tables that serve the same purpose. Even though the organization is better, it hinders performance.

You should have a blog table that holds the different blogs and assigns an id to each one (via auto_increment). Then you have a post table that handles all post for a blog, just put the blog id somewhere in the post table and it will be simple.

Then to make sure they submit comments to the right blog, just use the blog id in the action attrib of the form tag or use a hidden input field.


I took your advice and made the tables you suggested.
It's all starting to come together. This is a much more organized way of setting up the site.

I haven't quite gotten to modifying the HTML form, but thanks for the advice on the tables.


Okay, I've hit another wall.
In my blog comments table, I have a field for timestamps on each comment. It is in the DATETIME() format.
How can I store the current time in a DATETIME() format when the user clicks the submit button?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.