View Single Post
  #1  
Old 01-16-2005, 12:44 PM
varg
Unregistered

Posts: n/a

babstats server online

I'm trying to put a status note in my forums saying if our main server is running. Using babstats.
Here's what I've got so far, it's working, but it echoes all the servers. I'd like it to echo just the server with a certain ID - I guess that has to be specified in the $query, but I'm not sure how to do just that.

[code:1:26d24b6abe]
<?
$dbh=mysql_connect ('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db(dbname,$dbh) or die(mysql_error());


$query = mysql_query("SELECT * FROM `bab_servers` ORDER BY name") or die(mysql_error());
$thetime = time();
while($row = mysql_fetch_array($query)) {
if($thetime > ($row[last_update] + 120)) {
echo "Server is offline";
} else {
echo "Server is online";
} }
?>

[/code:1:26d24b6abe]
this is how it looks now. as you can see, it shows the offline servers aswell. While I only want it to show the last, online server, which is ID=5 in the database.
I'm no php expert, so help is most appreciated

//EDIT:
problem fixed, you can now delete this post if you want to.
in case someone wants to know
[code:1:26d24b6abe]
$dbh=mysql_connect ('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db(dbname,$dbh) or die(mysql_error());
$id = "5";
$query = mysql_query("SELECT * FROM `bab_servers` WHERE id=$id") or die(mysql_error());
$thetime = time();
while($row = mysql_fetch_array($query)) {
if($thetime > ($row[last_update] + 120)) {
echo "<a href=\"http://www.mapmakersheaven.com/server.php\">server is<font size=\"2\" color=\"#871C01\"><strong> offline </strong></font></a>";
} else {
echo "<a href=\"http://www.mapmakersheaven.com/server.php\">server is<font size=\"2\" color=\"#006600\"><strong> online </strong></font></a>";
} }[/code:1:26d24b6abe]
Reply With Quote