Macsure Posted October 25, 2013 Share Posted October 25, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/283273-need-help-making-a-script/ Share on other sites More sharing options...
Solution Ch0cu3r Posted October 25, 2013 Solution Share Posted October 25, 2013 (edited) 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 October 25, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/283273-need-help-making-a-script/#findComment-1455411 Share on other sites More sharing options...
Macsure Posted October 26, 2013 Author Share Posted October 26, 2013 Wow, quick response Thankyou so much Ch0cu3r, Looking at at the code now, yr explanation, I kinds fella bit foolish Once thanks Quote Link to comment https://forums.phpfreaks.com/topic/283273-need-help-making-a-script/#findComment-1455484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.