PDA

View Full Version : Mod help


pein87
08-04-2009, 03:17 PM
I/m working on a mod and I posted in the wrong section. What I'm trying to do is get the socialgroup leader, and member count from the socialgroups and then display them in an small div based layout on a new page. Its for RPG on my site. I was wondering how to go about doing this as my code didnt display anything.


$groupInfo = $vbulletin->db->query_read("SELECT socialgroupcatagoryid, name, creatoruserid, members FROM ". THREAD_PREFIX. " `socialgroup`");
$groupArray = $vbulletin->db->fetch_array($groupInfo);
$groupLeader = $groupArray['creatoruserid'];
$groupMembers = $groupArray['members'];
sprintf($groupLeader);
sprintf($groupMembers);


I added that to a template to see if it would work and it didnt. I want to only display them if there in a certain catagory and have them show the creators user name and member count. I tried to add the code into the php file but I got DB errors saying databaseName.thread_prefix does not exist.
I wanted to create a tag/badge for each group showing there leader and member count while haveing the images look difrrent based on the groups name.

Lynne
08-04-2009, 03:41 PM
Usually when you do a fetch_array, you are looking to get more than one line back from the query, otherwise you would do a query_first. Are you trying to get one thing back or many? If many, you should put your fetch_array in a while loop (you can do a search on 'fetch_array' in the vb code and you'll find many examples).

pein87
08-04-2009, 11:03 PM
I'm trying to only get the name, the catagory id of the social group, the creators id and the member count of the group. I would do query_first instead? Would I apply it to the php script or to the template like in my example?

Lynne
08-04-2009, 11:22 PM
If you are only trying to get one row returned, then replace query_read with query_first and then you don't need the fetch_array line (query_first will fetch the variables also).

pein87
08-05-2009, 03:36 PM
Thanks but would I add it to a template or to the php file itself?

Lynne
08-05-2009, 03:57 PM
You cannot put php in a template - all php must go in the page or a plugin.