Jump to content

Keeping Track Of Clicks Within A Database


kelleydl
 Share

Recommended Posts

For my site I have a form where visitors enter comments and each comment is listed below the form inside a table. I want to put something like a voting system with 2 or 3 links for each comment. Meaning each comment is kept in a database, and I need to keep track of how many times each link has been clicked for that specific comment. I think I'm having trouble understanding how each comment can keep track of it. My code for index.php would be something like..while($row = mysql_fetch_array($req)){ echo "<tr>"; echo "<td>" . $row['name'] . "<br />" . $row['location'] . "<br />" . $row['moment'] . "</td>" ; echo <a href="somepage.php">Vote1</a>; echo <a href="somepage.php">Vote2</a>; echo "</tr>"; }echo "</table>";I hope I'm not confusing you with what I'm trying to say but I don't see how its suppose to know which comment its suppose to add the vote to...

Link to comment
Share on other sites

If the number of options for all comments is the same, then add a field in your comments table for each option, and keep the totals there. If comments can have different numbers of options, then you need a separate table to hold the options and totals. You can have a comment ID field that matches it to a particular comment.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...