runnerjp Posted May 27, 2008 Share Posted May 27, 2008 hey so i have created my own forum but i just wanted to know... how can i make it so it shows how many views it has had? Link to comment https://forums.phpfreaks.com/topic/107476-forum/ Share on other sites More sharing options...
Gighalen Posted May 27, 2008 Share Posted May 27, 2008 You'll need to implement a hits tracker of sorts. I have a table like id ip hits forumid time When a user hits the forum, it will check to see if they have viewed that forum within the past 24 hours. If they have NEVER visited before at all, it will add a new row with all their corresponding data. If they HAVE, but HAVEN't visited in the past 24 hours, it will UPDATE their row (by IP address) and set hits to $hits + 1 and update the time. If they HAVE visited and HAVE visited in the past 24 hours, it will do nothing, as to try and keep stats pretty accurate. Then to add up the stats you just do a SUM(hits) thingie with mysql. Hope I wrote that to where you can understand it lol. Link to comment https://forums.phpfreaks.com/topic/107476-forum/#findComment-550901 Share on other sites More sharing options...
runnerjp Posted May 27, 2008 Author Share Posted May 27, 2008 humm ok thing is i have my table like this CREATE TABLE `forumtutorial_posts` ( `postid` bigint(20) NOT NULL auto_increment, `author` varchar(255) NOT NULL default '', `title` varchar(255) NOT NULL default '', `post` mediumtext NOT NULL, `showtime` varchar(255) NOT NULL default '', `realtime` bigint(20) NOT NULL default '0', `lastposter` varchar(255) NOT NULL default '', `numreplies` bigint(20) NOT NULL default '0', `parentid` bigint(20) NOT NULL default '0', `lastrepliedto` bigint(20) NOT NULL default '0', PRIMARY KEY (`postid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; so parentid is basicly if a user has posted on sum1 lese thred it just adds that threads id so if i was doing it how you say i would add hits to it then do what lol Link to comment https://forums.phpfreaks.com/topic/107476-forum/#findComment-550964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.