I am trying to build a website with mysql and php. This is the first site I have attempted so I want to write a little plan and get some feedback.
The site allows users to add some text in a text field as a “comment”. Once the comment has been entered into the site it is added to the database where it can be voted for by other users.
When a new comment has been added to the database it needs to create a new page, e.g. http://www.xxxxx.com/commentname or http://www.xxxxxx.com/?id=99981.
There will be a list of “Comments” in the database along with the number of votes for each comment.
The home page will have two functions.
1) Allow users to add a “comment”
2) Display two tables, each with 20 rows containing most “popular comments” and “recent comments”
Each comment will generate its one page where the comment will be displayed. Here users can read the comment and Vote for the comment if they wish.
Please help me out by explaining how to do the following.
-Generate a new page whenever a comment is added to the database
-Add a vote to the vote count in the comment database.
-Display the top 20 most popular comments as per number of votes.
You only need a comment.php file with a MySQL query getting the given comment out of the database. I would recommend to use the comments primary key to get the comment. Using rewrites you can have a URL like this: http://www.xxxx.com/comment/1. If you need the redirect for a specific link structure ask again.
Just add a column to your table holding the votes. If you have logged in users and you want then to check their votes, create a new table for the votes and another table for the many to many realtion.
This is simply done by sorting in the MySQL queries and selecting only 20 results:
Any further questions?