I have 1 table with an id (auto increment), username, email, icon, comment, rating, date (on update current_timestamp, left empty as now() does not function so must pre-date) and counts.
What I want to do is set up a trigger for every insert (count + 1), for every delete (count -1). The end result would be used for pagination so if I have 10 comments 5 to a page (10/2) --> #pagination would have two pages. Anyway I would like to welcome myself to responsive web design using AJAX jquery, JSON etc;
My SQL code is shown below for an insert update on count but the count is not incrementing, how would I delete also!
DELIMITER $$
CREATE
TRIGGER `CommentsTrigger` BEFORE INSERT ON Comments
FOR EACH ROW
BEGIN
UPDATE Comments
SET counts = (Select COUNT(*) from Comments)+ 1;
END $$
DELIMITER;
version 5.5!
I think the value needs to be saved as an integer but that is a guess!