Jump to content

need help making a script


Macsure
Go to solution Solved by Ch0cu3r,

Recommended Posts

I am  learnng code and script too, Very new infact.


 


I bring data off a game server, which is .xml, and I mangered to write a script to make it work get get the result I wanted (see below)   :)


I basically have 5 x rows and 2 Columns. as you can see.



<!DOCTYPE html>
<html>
<head>
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}

</script>
</head>

<body onload="JavaScript:timedRefresh(60000);">
<style type='text/css'>
#table1
{
border:0;
color:000000;
height:400px;
overflow:auto;
}

td{
padding-left:20px;
padding-right:20px;
}

#div1
{
width:400px;
background-color:#ffffff;
}

</style>
<?php
echo '<div id=div1>';
$xml1=simplexml_load_file("http://vsk5-public34:Ysotg7TwfF@scripts.ac32.virtualskipper.com/getPlayersOnline.php");
$totalplayers=$xml1->nbplayers;
echo '<table id=table1 bgcolor=#ffffff>';
$xml=simplexml_load_file("http://vsk5-public34:Ysotg7TwfF@scripts.ac32.virtualskipper.com/getServersOnline.php");

echo '<tr><td cellpaddding=40px>Vsk5online Servers</td><td>'. $xml->nbservers. '</td></tr>';
echo '<tr><td cellpaddding=40px>Players Online </td><td>'.$totalplayers . '</td></tr>';
echo '<tr><td colspan=2>___________________________________________________</td></tr>';

foreach($xml as $server)
{
if ($server->login!='')
{
echo '<tr><td width=150px>host :</td><td>' .$server->login. '</td></tr>';
echo '<tr><td width=150px>server :</td><td>' .$server->servername. '</td></tr>';
echo '<tr><td width=150px>current players :</td><td>' .$server->playercount. '</td></tr>';
echo '<tr><td width=150px>maximum players :</td><td>' .$server->maxplayercount. '</td></tr>';
echo '<tr><td width=150px>boat class :</td><td>' .$server->currentvehiclename. '</td></tr>';
echo '<tr><td colspan=2>___________________________________________________</td></tr>';
}
}

echo '</table>';
echo '</div>';
?>
</body>
</html>

But now I am trying to 5 columns


 


Is there any chance  of you helping me out. If so then I can post  my  code etc,


 


Thanks in advance


 


Macsure


Link to comment
Share on other sites

  • Solution

You're outputting new table rows for each value for host, server, current player, max player and boat class. Instead output these as table columns, not as rows.

 

Output the table headings before the loop, then just echo the values as columns within a row.

echo '<tr><th>Host</th>';
echo '<th>Server</th>';
echo '<th width=150px>Current Players</th>';
echo '<th width=150px>Maximum Players</th>';
echo '<th width=150px>Boat Class</th></tr>';

foreach($xml as $server)
{
	if ($server->login!='')
	{
		echo '<tr><td>' .$server->login.  '</td>';
		echo '<td>' .$server->servername.  '</td>';
		echo '<td>' .$server->playercount. '</td>';
		echo '<td>' .$server->maxplayercount. '</td>';
		echo '<td>' .$server->currentvehiclename. '</td></tr>';
		echo '<tr><td colspan=5>_______________________________________________________________________________</td></tr>';
	}
} 
Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.