Fix my code :(

Status
Not open for further replies.

WhiteOut

New Member
Messages
111
Reaction score
0
Points
0
Can anyone edit this code to make everything stay on one line so it looks like a banner?
Right now it looks like this:
Login
Online
Map
Online
Character
Online

I want it to look like this:
Login: Online Map: Online, and so on.

Heres the code
Code:
<?PHP
error_reporting(0);
echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /></head><body bgcolor=\"black\"><table align=\"center\" bgcolor=\"black\">");
$IP = array(
"Login Server" => "69.122.11.109:6900",
"Character Server" => "69.122.11.109:6121",
"Map Server" => "69.122.11.109:5121",
"Patch Server" => "204.2.183.2:80",
); while(list($ServerName,$Host)=each($IP)) {
list($IPAddress,$Port)=explode(":",$Host);
echo("<tr><td style=\"text-align:center;color:white\">".$ServerName."</td></tr><tr><td>");
if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
echo("<div style=\"color:green;font-weight:bold;text-align:center;\">Online</div>");
fclose($fp);
}
else {
echo ("<div style=\"color:red;font-weight:bold;text-align:center;\">Offline</div>");
}
echo ("</td></tr>");
}
echo("</table></body></html>");
?>
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
it seems like you are putting the content into tables..although I can not really tell how the tables look, but you might want to strip the important information out of there, and then just echo it into one line without the <tr><td>...stuff
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
Try this
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><body>
<?php
error_reporting(0);
$IP = array(
"Login Server"       => "69.122.11.109:6900",
"Character Server"   => "69.122.11.109:6121",
"Map Server"         => "69.122.11.109:5121",
"Patch Server"       => "204.2.183.2:80"
);
?>
<table align="center" bgcolor="white"><tr>
<?php
foreach($IP as $Server => $Host) {
 list($IPAddress,$Port)=explode(":",$Host);
 echo '<td align="center">' . $Server . '</td>';
 if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
  echo'<td style="text-align:center; color:green">Online</td>';
 }
 else {
  echo'<td style="text-align:center; color:red">Offline</td>';
 }
}
?>
</tr></table></body></html>
 
Last edited:

WhiteOut

New Member
Messages
111
Reaction score
0
Points
0
Thanks, that worked, but how can I change the color of the server names?
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
If you need to give a color to Server Names just replace
PHP:
echo '<td align="center">' . $Server . '</td>';
with
PHP:
echo '<td style="text-align: center; color:COLOR_VALUE">' . $Server . '</td>';

If you need to give different colors for each servers, you can't use loop. For that, you have to give specific color and write code for each server to check their status.
 
Last edited:

WhiteOut

New Member
Messages
111
Reaction score
0
Points
0
Thanks. I have one last thing to ask.. Is there a way to space them out more? They seem too close together and its hard to read.
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
Change
Code:
<table align="center" bgcolor="white"><tr>
with
Code:
<table align="center" bgcolor="white" cellspacing="2" cellpadding="2"><tr>
 

WhiteOut

New Member
Messages
111
Reaction score
0
Points
0
Thanks but that spaced everything out. I just want the space between each server bigger.
Right now its like this:
Login Server: Online Map Server: Online Character Server: Online
I want the space between 'Online Map Server' to be bigger and 'Online Character Server'
 
Last edited:

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
Completed via IM. Closing thread.
 
Last edited:
Status
Not open for further replies.
Top