PDA

View Full Version : Column count in Profile


Takara
06-08-2002, 10:06 AM
Im trying to use some stuff that FireFly did before to add the number of times a user made a new thread in a certin amount of forums (they work as columns).

Inside of members.php I added the following
// get the total number of columns posted
$columns=$DB_site->query("SELECT postuserid,count(*) AS totalcolumns FROM thread WHERE forumid IN (25,26,27,28,29,30,31) AND postuserid = $userid GROUP BY postuserid");
if (!isset($columns[totalcolumns])) {
$total_columns="";
} else {
eval("\$total_columns = \"".gettemplate("column_total")."\";");
}

Thats near the bottem, then of course I have a template column_total, it simply reads<tr>
<td bgcolor="{firstaltcolor}"><normalfont><b>Total <a href="forumdisplay.php?s=$session[sessionhash]&forumid=24">Columns</a>:</b></normalfont></td>
<td bgcolor="{firstaltcolor}"><normalfont>$columns[totalcolumns]</normalfont></td>
</tr>

And then inside my getinfo template I put $total_columns right after the 'Total Posts:' part. Thing is, it always returns as not set (I know because I assigned a value where it says $total_columns=""; )
Im assuming the problem is that $userid isnt right, I also tried $user[userid]. How can I get the userid of the profile that is being requested?

Thanks :bunny:

Takara
06-08-2002, 10:10 AM
Hmm, well. $userid is right, I just made sure. So it must be my query then? But it works when I try it via mysql
mysql> SELECT postuserid,count(*) AS totalcolumns FROM thread WHERE forumid IN (25,26,27,28,29,30,31) AND postuserid = 4 GROUP BY postuserid -> ;
+------------+--------------+
| postuserid | totalcolumns |
+------------+--------------+
| 4 | 3 |
+------------+--------------+
1 row in set (0.00 sec)

mysql>


What am I doing wrong >_<

Admin
06-08-2002, 11:26 AM
You need to use the query_first() method:
$columns=$DB_site->query_first("SELECT postuserid,count(*) AS totalcolumns FROM thread WHERE forumid IN (25,26,27,28,29,30,31) AND postuserid = $userid");
(And also don't need the GROUP BY clause)

Takara
06-08-2002, 12:04 PM
hehe, thanks FireFly.

If I dont add the order by I get this icky error
Invalid SQL: SELECT postuserid,count(*) AS totalcolumns FROM thread WHERE forumid IN (25,26,27,28,29,30,31) AND postuserid = 4
mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

:) Thanks for the help again

Admin
06-08-2002, 02:45 PM
Oops, sorry, you DO need the GROUP BY. Bring that back and it'll work. :)

Chris M
06-08-2002, 03:18 PM
Chen...

How would I remove these Queries?

INSERT INTO setting (settingid,settinggroupid,title,varname,value,desc ription,optioncode,displayorde r) VALUES (NULL,26,'Admin Maximum Width','amw','100','Maximum width (in pixels) that the custom avatar image can be for admins.','','6')

INSERT INTO setting (settingid,settinggroupid,title,varname,value,desc ription,optioncode,displayorde r) VALUES (NULL,26,'Admin Maximum Height','amh','100','Maximum height (in pixels) that the custom avatar image can be for admins.','','6')

INSERT INTO setting (settingid,settinggroupid,title,varname,value,desc ription,optioncode,displayorde r) VALUES (NULL,26,'Admin Maximum File Size','amfs','20000','The maximum file size of admins (in bytes) that an avatar can be.','','6')

?

Using the SQL Query in Admin CP hack...

Satan

Admin
06-08-2002, 03:33 PM
Did you hear something?

Chris M
06-08-2002, 04:38 PM
Huh?

Satan

Takara
06-08-2002, 08:59 PM
*explodes from confusion*

Hey firefly, I would seriously like to thank you for all your help. I'm usually able to code most of what I want to do, but my coding is always messy, and half the time I dont even know what I'm doing. You're always here when I need a little bit of my code corrected.

Thanks very much

/me goes back to coding her messy code

Admin
06-09-2002, 05:25 AM
You're welcome as always, Takara. :)