Count

Started by FTWR, October 24, 2011, 07:16:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FTWR

Thanks TheHippy, it work, thanks alot!!

ChubbyNinja

#4
what are the options for promotion?
for instance you could do

Code (php) Select

$res = mysql_query("SELECT COUNT(*) AS `total`,`owner` FROM torrents GROUP BY `owner`") or print(mysql_error());
while($row = mysql_fetch_array($res))
{
switch($row['total'])
{
case $row['total'] <= 10:
// uploaded 10 or less torrents so do something
break;
case $row['total'] <= 20:
// uploaded 20 or less torrents so do something
break;
case $row['total'] <= 30:
// uploaded 30 or less torrents so do something
break;
case $row['total'] <= 40:
// uploaded 40 or less torrents so do something
break;
}
}


that sort of thing.. That's how I'd do it however I'm not familiar with the db layout.. although given your example below i cant see why that wont work

FTWR

I understand, I'll wait until you can help me, but please do not forget, I need this code. Best of luck!

Mindless

#2
Off course that wont work in cleanup, for one that code is assuming you have a user query further up to draw current $user['id'] totals and because its userdetails you access that page with $id which the user query grabs for your information, so dropping that into cleanup is a fail straight away, the code required will need to select the posts and torrents probably inner or left joined to users to first grab the required info thats the principle requirement, once those counts are found you then go on to the update querys that will promote to the desired set class once the set out specification is met. But like i said its not a viable option for cleanup cos cleanup cant grab userid's its only a script that runs querys pertaining to data's on the tracker. I'll think how it can be achieved and post something when i get time to do so.

FTWR

Hello, I apologize if my post it's in the wrong section but I thought my problem fits here. I need emergent help with a small script that gives me trouble, I want to implement a script to count cleanup.php uploaded torrents and forum posts of each user in part, for user class promotion. I found this code in userdetails.php:

Quote//Uploaded Torrents 
   $res3 = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner=" . $user["id"] ."") or print(mysql_error());
   $row2 = mysql_fetch_row($res3);
   $uploaded_torrents = $row2[0];
//Forum Posts
   $res = mysql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user['id']) or sqlerr();
    $arr3 = mysql_fetch_row($res);
    $forumposts = $arr3[0];

but doesn't work in cleanup.php, i don't understand why. I need to tell you that i'm using Tbdev 2009, the source that U-232 is based, so code should resemble. I apologize if I was rude and I upset anyone, I just look for help from members of this community. Thanks a lot!