Hello everyone,

I have a database with a list of characters and I would like to display which characters are currently logged in on a webpage I have.

My database looks like this:

`characters` (`account`, `name`, `online`) VALUES (6, 'Frod', 1);

I hope that makes sense.

So if 'online' = 1 the character is currently logged in.
I would like to access the database and pull only the names that have the value of 1 in 'online' and display them in alphabetical order (if possible).

Can this be done in MySQL?

I'm not very knowledgeable when it comes to creating code. This is what I've tried.

@mysql_connect("localhost","root","ascent") OR die(mysql_error());
@mysql_select_db("funcharacters") OR die(mysql_error());
$query = @mysql_query("SELECT * FROM characters WHERE online = 1") OR die(mysql_error());
$whoonline = @mysql_num_rows($query);
echo "Who's Online: $whoonline";

However that code only displays the number of people online.

Any help is appreciated.

6 Years
Discussion Span
Last Post by mrcniceguy

it may be something like this...i havent tasted the code.

/*Database connection*/
/*below our query*/
$query= mysql_query("SELECT name FROM characters WHERE online ='1'  ORDER BY name") OR die(mysql_error());
/*check if there is anyone online*/
   $msg="There are $count Members Online<br/>";
 $msg="There are No members online<br/>";
echo"$msg<br/>";/* display message*/
$name = $row['name'];
echo "$name is  Online<br/>";

Edited by mrcniceguy: n/a

Votes + Comments
Excellent Knowledge
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.