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.
<?php @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.