garry Posted May 30, 2008 Share Posted May 30, 2008 Got another question for the helpful guys here at phpfreaks I've got a function which controls the amount of users online, here it is: function users_online($usersonline) { if (isset($_SESSION['logged_in'])) { $ses = session_id(); $time = time(); $timech=$time-600; $userid = $_SESSION['user_id']; $result = mysql_query("SELECT * FROM usersonline WHERE session='$ses'"); $num = mysql_num_rows($result); if ($num == "0"){ $result1 = mysql_query("INSERT INTO usersonline (session, time, user_id)VALUES('$ses', '$time', $userid)"); } else { $result2 = mysql_query("UPDATE usersonline SET time='$time' WHERE session = '$ses'"); } $result3 = mysql_query("SELECT * FROM usersonline"); $usersonline = mysql_num_rows($result3); mysql_query("DELETE FROM usersonline WHERE time < $timech"); return $usersonline; } } So basically what I want to know is how I can get this variable of $usersonline, outside of the function so I can use it on some pages that I want to. I've done some google and haven't found a whole lot so some help would be gladly appreciated! Quote Link to comment Share on other sites More sharing options...
garry Posted May 30, 2008 Author Share Posted May 30, 2008 anyone? I'm pretty sure this isn't that hard Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 30, 2008 Share Posted May 30, 2008 anyone? I'm pretty sure this isn't that hard what about just using include (filename); on the pages you want to call it on and just plug the variable in right??? Quote Link to comment Share on other sites More sharing options...
garry Posted May 30, 2008 Author Share Posted May 30, 2008 I'd rather use a function but I guess I could do that. If anyone figures out how to do it with a function i'd still like to know! Thanks for your help anyway Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 30, 2008 Share Posted May 30, 2008 I'd rather use a function but I guess I could do that. If anyone figures out how to do it with a function i'd still like to know! Thanks for your help anyway so when not just pull the result from the db instead at each page you want and echo it? Is that what you want? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.