Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 230
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 200
Total: 200

Author Topic: Help - With Download Count  (Read 8817 times)

0 Members and 1 Guest are viewing this topic.

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Help - With Download Count
« on: November 02, 2013, 08:50:20 am »
I am try to create a function on another page but I require the download count without duplicates for a certain period.

This is the code I have to count the downloads after a certain date:

Code: [Select]
$dbresult = $smcFunc['db_query']('', "

SELECT

ID_LOG

FROM {db_prefix}down_downloads_log

WHERE ID_MEMBER = " . $user_info['id']. " AND date >= $subsperiod ");

//$totalRow = $smcFunc['db_fetch_assoc']($dbresult);

$totalRow['total'] = mysql_num_rows($dbresult);

$count=$totalRow['total'];


What I am requesting from you is how to I re write this query so that duplicate downloads are only counted as 1

Can you help?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Help - With Download Count
« Reply #1 on: November 02, 2013, 09:42:57 am »
Change to
Code: [Select]

Code:

$dbresult = $smcFunc['db_query']('', "

SELECT

count(distinct id_file) as total

FROM {db_prefix}down_downloads_log

WHERE ID_MEMBER = " . $user_info['id']. " AND date >= $subsperiod ");

      $totalRow = $smcFunc['db_fetch_assoc']($dbresult);



$count=$totalRow['total'];
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Re: Help - With Download Count
« Reply #2 on: November 02, 2013, 09:45:42 am »
Awesome thanks and you got a bump on your topic on the other site.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Help - With Download Count
« Reply #3 on: November 02, 2013, 09:47:34 am »
Nice!
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Re: Help - With Download Count
« Reply #4 on: November 01, 2016, 11:06:50 am »
This code you gave me doesnt seem to work with the updated database.

Any chance you could check it for me please.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Help - With Download Count
« Reply #5 on: November 01, 2016, 11:09:50 am »
What do you mean by updated database? Do you get an error?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Re: Help - With Download Count
« Reply #6 on: November 01, 2016, 11:11:16 am »
No mate. It just does not return the result of the count

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Help - With Download Count
« Reply #7 on: November 01, 2016, 11:12:04 am »
Can you show me the exact code you are using?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Re: Help - With Download Count
« Reply #8 on: November 01, 2016, 11:13:40 am »
I have this code in Downloads2.template.php

Code: [Select]
$dbresult = $smcFunc['db_query']('', "
SELECT
count(distinct ID_LOG) as total
FROM {db_prefix}down_downloads_log
WHERE ID_MEMBER = " . $user_info['id'] . " AND date > ($datea) ");
//$totalRow = $smcFunc['db_fetch_assoc']($dbresult);

$totalRow['total'] = mysql_num_rows($dbresult);

$counttotal=$totalRow['total']-1;
$tot=$totalRow['total'];

Where $datea is the end date of a subscription less 30days using this code:

Code: [Select]
//////////////////////////////////////////////////////Gets end date of subscription

$request = $smcFunc['db_query']('', '
  SELECT end_time
  FROM {db_prefix}log_subscribed
  WHERE id_member = {int:member}',
  array(
    'member' => $user_info['id'],
  )
);
if ($smcFunc['db_num_rows']($request) != 0)
{
  list ($result) = $smcFunc['db_fetch_row']($request);
}
else
  $result = false;
$smcFunc['db_free_result']($request);
$enddate=$result;


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Help - With Download Count
« Reply #9 on: November 01, 2016, 11:15:58 am »
You should change this back
Code: [Select]
//$totalRow = $smcFunc['db_fetch_assoc']($dbresult);

$totalRow['total'] = mysql_num_rows($dbresult);
To
Code: [Select]
$totalRow = $smcFunc['db_fetch_assoc']($dbresult);

Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline elbeer

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 111
    • View Profile
Re: Help - With Download Count
« Reply #10 on: November 01, 2016, 11:25:39 am »
Nope still not counting them

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
2814 Views
Last post February 10, 2007, 04:19:58 am
by Sharr76
0 Replies
3782 Views
Last post March 01, 2007, 11:16:11 am
by marcbkk
1 Replies
4008 Views
Last post July 28, 2008, 06:44:00 pm
by Mysterium X Symbolum
10 Replies
8685 Views
Last post September 06, 2013, 12:26:50 pm
by SMFHacks
11 Replies
9966 Views
Last post October 26, 2013, 08:06:38 am
by SMFHacks

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal