将两个表放在同一行html中

时间:2014-09-10 15:35:42

标签: php html

我该怎么把两张桌子放在同一条线上?下面的代码显示我的表格转到新行。请帮我 。我想在HTML

这是我的表格。我想把它们放在一行

enter image description here

这是我的代码

  <table border="1">
    <tr>
        <td><b>#</b></td>
        <td><b>Request ID</b></td>
        <td><b>Title</b></td>
        <td><b>Importance</b></td>
        <td><b>Date</b></td>
        <td><b>Status</b></td>
        <td><b>View/Reply</b></td>
    </tr>

    <?php
    $a=1;
    $res = mysql_query("SELECT * FROM request WHERE req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC");
    while ($row = mysql_fetch_array($res)){ ?>

    <tr>
        <td><?php echo $a; ?></td>
        <td><?php echo $row['req_id']; ?></td>
        <td><?php echo $row['req_title']; ?></td>
        <td><?php echo $row['req_important']; ?></td>
        <td><?php echo $row['req_dateReceive']; ?></td>
        <td><b><?php echo $row['req_status']; ?></b></td>
        <?php
        if( $row['req_status'] == "UNDONE") { ?>
            <td><a href="viewRequestAdmin.php?var1=reply&var=<?php echo $row['req_id']; ?>"><image src = "reply.jpg" height="65" width ="80"></a></td>
        <?php
        }
        else { ?>
            <td><a href="viewRequestAdmin.php?var1=view&var=<?php echo $row['req_id']; ?>"><image src = "view2.jpg"></a></td>
        <?php
        }
        ?>
    </tr>
    <?php
    $a++;
    } ?>
    </table>

    <td>
    </td>


        <table border="1">
    <tr>
        <td><b>#</b></td>
        <td><b>Request ID</b></td>
        <td><b>Title</b></td>
        <td><b>Importance</b></td>
        <td><b>Date</b></td>
        <td><b>Status</b></td>
        <td><b>View/Reply</b></td>
    </tr>

    <?php
    $a=1;
    $res = mysql_query("SELECT * FROM request WHERE req_status = 'DONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC");
    while ($row = mysql_fetch_array($res)){ ?>

    <tr>
        <td><?php echo $a; ?></td>
        <td><?php echo $row['req_id']; ?></td>
        <td><?php echo $row['req_title']; ?></td>
        <td><?php echo $row['req_important']; ?></td>
        <td><?php echo $row['req_dateReceive']; ?></td>
        <td><b><?php echo $row['req_status']; ?></b></td>
        <?php
        if( $row['req_status'] == "UNDONE") { ?>
            <td><a href="viewRequestAdmin.php?var1=reply&var=<?php echo $row['req_id']; ?>"><image src = "reply.jpg" height="65" width ="80"></a></td>
        <?php
        }
        else { ?>
            <td><a href="viewRequestAdmin.php?var1=view&var=<?php echo $row['req_id']; ?>"><image src = "view2.jpg"></a></td>
        <?php
        }
        ?>
    </tr>
    <?php
    $a++;
    } ?>
    </table>

4 个答案:

答案 0 :(得分:0)

使用以下代码:

table.twoinline {
   width: 49%
}

<table class="twoinline">
...
...
...
</table>
<table class="twoinline">
...
...
...
</table>

答案 1 :(得分:0)

非CSS解决方案。 (根据要求)

创建一个表,并将每个表放在一个自然落入列的单元格中

<table>
  <tr>
    <td>
      <table>
        <!-- LEFT TABLE -->
      </table>
    </td>
    <td>
      <table>
        <!-- RIGHT TABLE -->
      </table>
    </td>
  </tr>
</table>

最好将一些div作为列浮动而不是

CSS

.floatLeft {
  width: 50%;
  float: left;
}

HTML

<div class="floatLeft">
  <table></table>
</div>
<div class="floatLeft">
  <table></table>
</div>

<小时/>

答案 2 :(得分:0)

display:inline-table;

Demo Fiddle here

Documentation here

答案 3 :(得分:0)

也许这个? (缩进不好):

<style type="text/css" media="screen">
         table { border: 1px solid black;float:left;width:148px;}
     #table_container{width:300px;margin:0 auto;}
</style>

    <div id="table_container">
  <table>
    <tr>
      <th>#</th>
      <th>Request ID</th>
      <th>Title</th>
      <th>Importance</th>
      <th>Date</th>
      <th>Status</th>
      <th>View/Reply</th>
    </tr>
    <?php
    $a=1;
    $res = mysql_query("SELECT * FROM request WHERE req_status = 'UNDONE' ORDER BY req_status     DESC,req_important ASC,req_dateReceive DESC");
    while ($row = mysql_fetch_array($res)){ ?>
        <tr>
        <td><?php echo $a; ?></td>
        <td><?php echo $row['req_id']; ?></td>
    <td><?php echo $row['req_title']; ?></td>
    <td><?php echo $row['req_important']; ?></td>
    <td><?php echo $row['req_dateReceive']; ?></td>
    <td><b><?php echo $row['req_status']; ?></b></td>
    <?php
    if( $row['req_status'] == "UNDONE") { ?>
        <td><a href="viewRequestAdmin.php?var1=reply&var=<?php echo $row['req_id']; ?>"><image src = "reply.jpg" height="65" width ="80"></a></td>
    <?php
    }
    else { ?>
        <td><a href="viewRequestAdmin.php?var1=view&var=<?php echo $row['req_id']; ?>"><image src = "view2.jpg"></a></td>
    <?php
    }
    ?>
</tr>
<?php
$a++;
    } ?>
  </table>
  <table>
    <tr>
  <th>#</th>
  <th>Request ID</th>
  <th>Title</th>
  <th>Importance</th>
  <th>Date</th>
  <th>Status</th>
  <th>View/Reply</th>
</tr>
<?php
$a=1;
$res = mysql_query("SELECT * FROM request WHERE req_status = 'DONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC");
while ($row = mysql_fetch_array($res)){ ?>

<tr>
    <td><?php echo $a; ?></td>
    <td><?php echo $row['req_id']; ?></td>
    <td><?php echo $row['req_title']; ?></td>
    <td><?php echo $row['req_important']; ?></td>
    <td><?php echo $row['req_dateReceive']; ?></td>
    <td><b><?php echo $row['req_status']; ?></b></td>
    <?php
    if( $row['req_status'] == "UNDONE") { ?>
        <td><a href="viewRequestAdmin.php?var1=reply&var=<?php echo $row['req_id']; ?>"><image src = "reply.jpg" height="65" width ="80"></a></td>
    <?php
    }
    else { ?>
        <td><a href="viewRequestAdmin.php?var1=view&var=<?php echo $row['req_id']; ?>"><image src = "view2.jpg"></a></td>
    <?php
    }
    ?>
    </tr>
    <?php
    $a++;
    } ?>
  </table>

  </div>