/    Sign up×
Community /Pin to ProfileBookmark

Output tables to appear next to eachother rather than below eachother from a php loop

I think this is a php problem although it may just be a HTML problem. I have a php loop that outputs data into a HTML table. I want the tables that are being repeated to the screen to sit by the right side of the last table produced so they sit by the side of eachother and not below each other.

<body>

<table border=”1″ width=””>
<tr><td>System Name: </td></tr>
<tr><td>System Uptime: </td></tr>
<tr><td>Current Tcp connections: </td></tr>
<tr><td>Port 0: </td></tr>
<tr><td>Status: </td></tr>
<tr><td>Port 1: </td></tr>
<tr><td>Status: </td></tr>
</table>

<?php

// Loop
for($i=1;$i<=$maxhost;$i++)
{

// Request system name value
$sysname=snmpget($host[$i], $community, $requestval[1]);

// Request system uptime and format for output
$sysup=snmpget($host[$i], $community, $requestval[2]);
$sysupre=eregi_replace(“([0-9]{3})”,””,$sysup);
$sysupre2=eregi_replace(“Timeticks:”,””,$sysupre);
$sysupre3=eregi_replace(“[()]”,””,$sysupre2);

// Request tcp connections and format for output
$tcpcon=snmpget($host[$i], $community, $requestval[3]);
$tcpconre=eregi_replace(“Gauge32:”,””,$tcpcon);

// Request Interface status

$ifdsc0=snmpget($host[$i], $community, $requestval[4]);
$ifstat0=snmpget($host[$i], $community, $requestval[5]);
$ifdsc1=snmpget($host[$i], $community, $requestval[6]);
$ifstat1=snmpget($host[$i], $community, $requestval[7]);

// Output to page

?>

<?php

//everytime the loop goes round i need the new table to appear
//by the side of the last table produced.

echo “<table width=”10%” border=”0″>”;
echo “<tr><td>”.$sysname.”</td></tr>”;
echo “<tr><td>”.$sysupre3.”</td></tr>”;
echo “<tr><td>”.$tcpconre.”</td></tr>”;
echo “<tr><td>”.$ifdsc0.”</td></tr>”;
echo “<tr><td>”.$ifstat0.”</td></tr>”;
echo “<tr><td>”.$ifdsc1.”</td></tr>”;
echo “<tr><td>”.$ifstat1.”</td></tr>”;
echo “</table>”;

}

?>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJan 06.2005 — One solution is to not generate these as separate tables -- but as additional columns in a single table. The other solution is to code [B]style="float:left;"[/B] in those tables which must allow another table to their right.
Copy linkTweet thisAlerts:
@scragarJan 06.2005 — I don't quite get your point but do you want all the tables to appear along side oneanother or just repeats? and if it's the later can't you just use distinct in your mySQL?
Copy linkTweet thisAlerts:
@Daot_LagorilleJan 06.2005 — I think this is just an html thing.

Similar to the solution presented above, do this:

Create an adittional table that will contain each data table:

[code=php]
<table>
<tr>
<?php do { ?>
<td>
Data table goes here
</td>
<?php } while (blah blah blah); ?>
</tr>
</table>


[/code]
×

Success!

Help @peter_butler spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...