PDA

View Full Version : New box under "What's going on?" which contains information from another database?


sebbe
04-09-2006, 10:21 PM
I've really tried to search for help but I couldn't find anything usefull. I haven't really modified any vB pages this way before so now I'm gonna ask you experts! :)

I want to create another box under the "Currently Active Users". It will contain info about how many users are active in our chat.

This is how it looks:
http://img450.imageshack.us/img450/6885/chat8hn.jpg

I tried to add the code below in the forumhome template but it won't work. Anyone have any ideas of how I can make this work?

Here's the code I use for the script:
<!-- Chat Stats -->
<?php
$db=mysql_connect("*****", "*****", "*****");
mysql_select_db("*****", $db);

$query = "*****";
$result = mysql_query($query) or die(mysql_error);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];

$query3 = "*****";
$result3 = mysql_query($query3) or die(mysql_error());

list($chattername) = mysql_fetch_array($result3);

?>

<table class="tborder" cellpadding="5" cellspacing="1" border="0" width="100%" align="center">
<tbody>
<tr>
<td class="thead" colspan="2">

<a style="float:right" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="eablue/buttons/collapse_thead.gif" alt="" border="0" /></a>
<a href="*****" target="_blank">Currently Active Users In EA Chat</a>: <?php echo $numrows ?>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="">
<tr>
<td class="alt2"><a href="*****" target="_blank""><img src="chat.gif" alt="pic" border="0" height="20" width="20" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">

<div style="white-space: nowrap">Most active chatter: <b><?php echo $chattername ?></b></div>
<div>
<?php
$query2 = "*****";
$result2 = mysql_query($query2) or die(mysql_error());

while(list($name) = mysql_fetch_array($result2))
{
echo $name . ", ";
}
?>
</div>

</div>
</td>
</tr>
</tbody>
<?php
mysql_close();
?>
<!-- //Chat Stats -->

Any help is appreciated.
Thanks in advance! :)

Paul M
04-09-2006, 10:55 PM
You cannot put php code in templates - you need to create a plugin for the code and just put the output variable in the template.

sebbe
04-10-2006, 06:01 AM
You cannot put php code in templates - you need to create a plugin for the code and just put the output variable in the template.

I see. I tried to read pages about hooks & plugins but is all that really necessary for this matter?

Isn't there any easy way to do this? :)

Edit: I followed this (https://vborg.vbsupport.ru/showthread.php?t=82625) guide and made a plugin. It works if I place it in the index.php like Brad did in that guide but when I try to add it to the template where I want it, it just says:
http://img125.imageshack.us/img125/5559/lolz8ta.jpg

Any ideas? :cool:

sebbe
04-12-2006, 07:29 PM
No one? Shouldn't be too hard eh? :cool: