forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Tasemu on October 14, 2010, 08:49:49 am
-
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. ^^
-
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
SELECT owner_id, COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} GROUP BY owner_id
-
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:
$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
-
Sry bout the double post but i couldnt find how to edit the post and thought this info will be useful:
while($row2 = mysql_fetch_array($result2))
<----- This is line 59 in the error haha. ^^
-
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.
-
Haha yeah, cheers mate. I realised that earlier but wasnt brave enough to triple post haha. ^^
-
[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]
-
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.
-
Moving to misc.