Jump to content
Larry Ullman's Book Forums

Chapter 3 Script 3 2 Excellent Boring Exercise


Recommended Posts

Re script 3 2 which I have customized to fit a webpage of mine on political cartoons...I replaced excellent with "funny" etc...so that is the project. What I would like is info on how to tally the votes I place on each cartoon and a sum of those votes. Just a general idea of what I should do next is O.K. because I am new at PHP. I know CSS and HTML, that's it. So, I would like to be pointed to info where I can learn to tally my votes and see that the tally corresponds to the votes I make. I have of course this book edition on my Kindle, and think it will give me the basics in which I am now beginning. Thanks..Nadeltanz

Link to comment
Share on other sites

I suppose something as simple as adding an additional column to the DB for each cartoon for the number of "likes" would be sufficient.

Each time someone clicked the "Like" button, you could increment the counter in the DB for that cartoon by 1.

And when you're displaying the cartoons, you'd just pull the "likes" column from the DB as well.

 

The tricky part would probably be making sure that the "Like" button for an individual cartoon could only be clicked once per user.

Link to comment
Share on other sites

HartleySan's suggestion will work fine. If you need to be more exacting, such as limiting each person to one like, you'd need to create a separate likes table with the cartoon id and the user id as the composite key. You could then use fancy SQL to count the likes.

Link to comment
Share on other sites

 Share

×
×
  • Create New...