Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Aligning two tables next to one another

    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...
    Code:
    <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...
    Code:
    <?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

  • #2
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From your included .php file:
    Code:
    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

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

    I take no responsibility for the above nonsense.


    Left Justified

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd have to agree 100% with the mindless one. He knows what he's talking about.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •