Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Creating a simple points system plugin. Need Total uploads variable.  (Read 6316 times)

0 Members and 1 Guest are viewing this topic.

Tasemu

  • Coppermine newbie
  • Offline Offline
  • Posts: 4

Gday mates.

I am running a coppermine gallery which is bridged to mybb. Basically its used for members to upload renders to. I was hoping to code a simple and non flashy plugin that will assign points based on 2 variables that are added together (posts on the forum + images uploaded) and will post the total points to a page that has a table of every member.

So basically it is a simple points system for each member that does images uploaded + Posts made.

What i was hoping to get help with is a way to get the value of the total images uploaded that is available in the users gallery profile so i can use it in the script.

Sorry if its a simple and stupid question but im hoping to cut time in the production because its needed quite soon.

Thanks in advance and peace out. ^^
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #1 on: October 14, 2010, 09:27:10 am »

Code: [Select]
global $CONFIG;
$user_id = 1234; // here you need to specify the user id
$pictures_count = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = $user_id"), 0);

Alternatively you can use a query like
Code: [Select]
SELECT owner_id, COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} GROUP BY owner_id
Logged

Tasemu

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #2 on: October 14, 2010, 12:42:07 pm »

Cheers mate. I still get a problem which ill outline now.

P.S. I have managed to get the username and postcount from the mybb database and post them into a table.

When trying to do the same with the coppermine database i use the following code:

Code: [Select]
$con2 = mysql_connect("localhost","username","password");
if (!$con2)
{
die('Could not connect to cpg: ' . mysql_error());
}
echo "connected to gallery users";

mysql_select_db("tasemu_cpg");

$result2 = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']}");

while($row2 = mysql_fetch_array($result2))
  {
  echo "<tr>";
  echo "<td>" . $row2['owner_id'] . "<td>";
  echo "<td>" . $row2['COUNT'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con2);


When i run the code i receive the following error for this code.

Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tasemu/public_html/forum/inc/mangarenderspoints/mangarenderspoints.php on line 59
Logged

Tasemu

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #3 on: October 14, 2010, 12:44:57 pm »

Sry bout the double post but i couldnt find how to edit the post and thought this info will be useful:

Code: [Select]
while($row2 = mysql_fetch_array($result2)) <----- This is line 59 in the error haha. ^^
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #4 on: October 14, 2010, 03:37:41 pm »

If you run your script out of Coppermine's scope, you have to replace {$CONFIG['TABLE_PICTURES']} with your picture table name. In that case your question is not related to Coppermine, but basic SQL knowledge.
Logged

Tasemu

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #5 on: October 14, 2010, 04:48:39 pm »

Haha yeah, cheers mate. I realised that earlier but wasnt brave enough to triple post haha. ^^
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #6 on: October 15, 2010, 06:42:15 pm »

[ot]
This thread doesn't belong into this board. Who moved it here in the first place? Stop using the "General Discussion" board, it's dead as a dodo and should remain that way: dead.
[/ot]
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #7 on: October 15, 2010, 06:47:01 pm »

I moved it, as I thought it was the best place for this topic because it's not really related to Coppermine support. It was started in the cpg1.5.x plugin support board.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Creating a simple points system plugin. Need Total uploads variable.
« Reply #8 on: October 15, 2010, 06:49:34 pm »

Moving to misc.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.