Jump to content

Arranging table horizontal


tjverge

Recommended Posts

I have a code that outputs a table but right now each result is under the next ex:

 

1

2

3

1

2

3

I would like them to be horizontal ex:

123

123

 

the part of the code the controls the table is:

echo "<table border=0 cellspacing=0 cellpadding=0>";
foreach($xml->result->rowset->row AS $name)
{
echo "<tr>";
echo "<td><img src=/Character/".$name['characterID']."_200.jpg></td></tr>";
echo "<tr><td>".ucwords($name['name'])."</td></tr>";
echo "<tr><td>".ucwords($name['corporationName'])."</td>";
echo "</tr>";
}
echo "</table>";

Link to comment
https://forums.phpfreaks.com/topic/233864-arranging-table-horizontal/
Share on other sites

They're on separate lines because of the <tr>'s. Remove those so it look like this:

echo "<tr>";
echo "<td><img src=/Character/".$name['characterID']."_200.jpg></td>";
echo "<td>".ucwords($name['name'])."</td>";
echo "<td>".ucwords($name['corporationName'])."</td>";
echo "</tr>";

This is what I came up with it works, but is there a better way to do it?

 

echo "<table border=0 cellspacing=0 cellpadding=0>";

echo "<tr>";

foreach($xml->result->rowset->row AS $name)

{

echo "<td><img src=http://image.eveonline.com/Character/".$name['characterID']."_200.jpg></td>";

}

echo "<tr>";

foreach($xml->result->rowset->row AS $name)

{

echo "<td>".ucwords($name['name'])."</td>";

}

echo "</tr>";

echo "<tr>";

foreach($xml->result->rowset->row AS $name)

{

echo "<td>".ucwords($name['corporationName'])."</td>";

}

echo "</tr>";

}

echo "</tr>";

echo "</table>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.