This site shows (x) users veiwing each forum on the main index, Id love to know how its done? can it be done with javascript?

i think its a php script maybe
i know nothing about web design though so take that with a pinch of salt

This forum uses PHP and the code is embedded into the software.

I do not know if it can be done with javascript.

It's not possible to do this with JavaScript because you would need some sort of database to keep track of how many visitors there are, which can only be done with a server-side programming language.

We do it with PHP and MySQL. Each time a page is accessed, a record in a MySQL table is updated with the user's IP address and the timestamp. Records with timestamps older than 20 minutes are deleted. The number of IP addresses is the number of people currently visiting the site.

ok Thanks again. I found a similar code that may need slight tweaking to work for me. I dont have a 'veiws' cell on my main index though.
could I rewrite this to add to cell 'Forum'? which list the forum name?

P.s Im aware of the advertising ban so I wont link you my site to see.

<script type="text/javascript">
Users Viewing In Main Page 
var addrequest;
var viewadds = new Array();
var curnum = 0;
var td = document.getElementsByTagName('td');
if(td[t].getElementsByTagName('a')[0] && td[t].getElementsByTagName('a')[0].href.match(/showforum=\d+/)){
function checkBViews(){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();
var opener = viewadds[curnum].getElementsByTagName('a')[0].href;
addrequest.onreadystatechange = function(){
function addBViews(){
if(addrequest.readyState == 4 && addrequest.status == 200){
var resptext = addrequest.responseText;
var addiv = document.createElement('div');
addiv.innerHTML = resptext;
var hdiv = addiv.getElementsByTagName('div');
var views = 0;
if(hdiv[a].className == "darkrow2" && hdiv[a].innerHTML.match(/^(\d+) User\(s\) are browsing this forum/)){
views = parseInt(RegExp.$1) - 1;
if(views < 0){
views = 0;
if(views != 0){
var viewstext = document.createTextNode( ' ('+views+' viewing'+')');
if(curnum != viewadds.length){
} else {
function termViews(){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();

p.s My templet for board index forum row. Where I have 'New topic' link is where I want Users Browsing

          <td class="row4" align="center">{$info['img_new_post']}</td>
          <td class="row4"><a href="{ibf.script_url}showforum={$info['id'] }"onMouseover="ddrivetip('Open This Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><b>{$info['name']}</b></a><br /><br><a href="{ibf.script_url}act=Post&CODE=00&f={$info['id']}"onMouseover="ddrivetip('Start A new Topic In this Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><FONT COLOR="#FF0000"><b>New Topic</b></font></a><br /><br><span class='desc'>{$info['description']}<br />

          <td class="row2" align="center">{$info['topics']}</td>
          <td class="row2" align="center">{$info['posts']}</td>

  <td class="row2" nowrap="nowrap">{$info['last_post']}<br />{}:&nbsp;{$info['last_unread']}{$info['last_topic']}

<br />{}: {$info['last_poster']}


p.s users browsing [forum/topic] is written in php my board

This article has been dead for over six months. Start a new discussion instead.