Jump to content
xisto Community
Sign in to follow this  
ewcreators

Very Simple Online Now Script This is a very simple online now script.

Recommended Posts

Hi all, Its Aldo.
anyways,
I wont be using the method of pagination, i will just tell you how to make a basic online now script.
When someone logs in,
now take into consideration that the name of the username input is username (<input type.... name=username)
First ,create a table in your database saying online now and add 2 fields to it. id and username

id type=integer(INT) , auto increment, length =255
and username = VARCHAR length=the limit a username should be in your site



now from there we take off :
<?php//logged.php//authentication script//connection script//if connection success $insert=mysql_query("INSERT into onlinenow (name) VALUES ('$_GET[username]')")or die(mysql_error());header('location:game.php');//if authentication or connection fails, redirect them to an error page.?>-----<?php//game.php//suppose you have a box display game data//in that box, you want to show NUMBER of people online$onlinecount=mysql_query("SELECT * from onlinenow");$ocount=mysql_num_rows($onlinecount);echo "Number of users online now: ".$ocount." ";?>------<?php//onlinenow.php//i wont be dividing results into different pagesecho "<table border=1><tr><th colspan=3>ONLINE NOW</th></tr>";echo "<tr><td>ID</td><td>NAME</td><td>OPTIONS</td></tr>";$oselect=mysql_query("SELECT * from onlinenow");while($online=mysql_fetch_array($oselect)) {echo "<tr><td>".$online['id']."</td><td>".$online['username']."</td>";echo "<td><a href='profile.php?a=$_SESSION[username]&s=$s&profile=$online[name]'>Visit Profile</a></td></tr>";}echo "</table>";?>
-----

if it doesn work or if you have suggestions, or opinions,,,please go ahead and edit :XD:

Notice from rvalkass:

Added closing code tag.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.