Jump to content

Keeping Track Of Clicks Within A Database


kelleydl

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...