Comments

dhtml

Sat 24 Feb, 2018 05:54 am

I can answer this question in many ways, but first you need to tell us the type of data you are looking for. But a likely solution is this:


step 1: create a table called hits with fields - ID (autoincrement), thread_id (int), user_id (int), time (int)

Step 2: each time the thread is visited, you can insert an entry into the table id, thread_id, user_id, time 
As for the time, you can use mysql timestamp or whatever you like


Step 3: to get the total number of people who visit the thread, do something like:

select count(*) from hits where thread_id=1 group by user_id (untested)

mista_cee

Sat 24 Feb, 2018 04:59 pm

Thanks sir...  Buh how I can get the hits is the problem,  what php function do I use? 

sunny

Sat 24 Feb, 2018 07:34 pm
From my little knowledge you can insert a code to update a thread hit column on every view. But you probably have to check it's not the same device or in other cases user. .

mrcodes

Sun 04 Mar, 2018 08:12 am
dhtml wrote:

I can answer this question in many ways, but first you need to tell us the type of data you are looking for. But a likely solution is this:


step 1: create a table called hits with fields - ID (autoincrement), thread_id (int), user_id (int), time (int)

Step 2: each time the thread is visited, you can insert an entry into the table id, thread_id, user_id, time 
As for the time, you can use mysql timestamp or whatever you like


Step 3: to get the total number of people who visit the thread, do something like:

select count(*) from hits where thread_id=1 group by user_id (untested)


I would also suggest this too

mrcodes

Sun 04 Mar, 2018 08:17 am
mista_cee wrote:

Thanks sir...  Buh how I can get the hits is the problem,  what php function do I use? 

From a laravel point of view, you can do this below


$hits = DB::select('select COUNT(*) AS total_hits from hits WHERE thread_id=2')->get();

OR

$hits = DB::table('hits')->where('thread_id', 2)->get();

and get your results with 

$hits->total_hits;