...

View Full Version : Aligning two tables next to one another



jlsohio
02-18-2006, 11:06 PM
I have these two tables that I'm pulling from my database. I would like to put one table on the left and one on the right. Right now, one is directly above the other one.

Here's the html...

<hr align="center" color="black" width="100%"/>

<P align="center"><font face="arial" size="6" color="black">2006 Top 3-Year-Old Colt Pacers</font>

<div align="center"><font face="arial" size="2" color="black">Sorted by Earnings</font>

<br />

<?php

include("2006_top_3yr_olds_a.php");
?>

</table>

<P align="center"><font face="arial" size="6" color="black">2005 Top 3-Year-Old Colt Pacers</font>

<div align="center"><font face="arial" size="2" color="black">Sorted by Earnings</font>

<br />

<?php

include("2006_top_3yr_olds.php");
?>

</table>

Or do I have to align the tables in my php file? here's the code from the php file...

<?php

include("connect.php");

?>

<?

//Begin your table outside of the array
echo "<table border=1 cellpadding=2 cellspacing=0 bordercolorlight=brown bordercolordark=brown bgcolor=ffffff width=35%>\n";

$table_row = "<tr align=\"center\" valign=\"middle\">";
$table_row .= "<th>Horse</th>";
$table_row .= "<th>Starts</th>";
$table_row .= "<th>1st</th>";
$table_row .= "<th>2nd</th>";
$table_row .= "<th>3rd</th>";
$table_row .= "<th>Record</th>";
$table_row .= "<th>YTD Earnings</th>";
echo "$table_row\n";

// Request the text of all the horses
$result = @mysql_query('SELECT Horse, Starts, First, Second, Third, Record, Earnings FROM 2006_top_3yr_olds ORDER BY Earnings DESC limit 25');
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}

// Display the text of each horse in a paragraph
while ( $row = mysql_fetch_array($result) ) {

$time = $row["Record"];
$time = substr_replace($time,'.',3,0);
$time = substr_replace($time,':',1,0);

$earnings=$row["Earnings"];

$var = $earnings;
$var = number_format($var);
$cym="$";

$table_row = "<tr align=\"center\" valign=\"middle\">";
$table_row .= "<td WIDTH=24%><font size=\"3\"><font face=\"arial\">$row[Horse]</td>";
$table_row .= "<td WIDTH=12%><font size=\"3\"><font face=\"arial\">$row[Starts]</td>";
$table_row .= "<td WIDTH=12%><font size=\"3\"><font face=\"arial\">$row[First]</td>";
$table_row .= "<td WIDTH=12%><font size=\"3\"><font face=\"arial\">$row[Second]</td>";
$table_row .= "<td WIDTH=12%><font size=\"3\"><font face=\"arial\">$row[Third]</td>";
$table_row .= "<td WIDTH=13%><font size=\"3\"><font face=\"arial\">$time</td>";
$table_row .= "<td WIDTH=15%><font size=\"3\"><font face=\"arial\">$cym$var</td>";
echo "$table_row\n";

}

?>

Thank you

mindlessLemming
02-18-2006, 11:17 PM
From your included .php file:

echo "<table border=1 cellpadding=2 cellspacing=0 bordercolorlight=brown bordercolordark=brown style='background:#fff; width:35%; float:left;'>\n";

floating the tables will cause them to be on the same line (so long as their combined widths + padding + margin is less than 100%)

Following that, you will need to clear your floats. The easiest way using html is to just stick this in after the second table:

<div style="clear:both;"><!-- --></div>

That's also the messiest way, but is easier for those new to CSS ;)

Learn CSS, it will make your life easier :) Here's a good place to start (http://htmldog.com/)

* Terms in italic can be used to search for more detail

Skyzyx
02-19-2006, 12:08 AM
I'd have to agree 100% with the mindless one. He knows what he's talking about. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum