如何并排显示表格的列?

时间:2017-11-30 13:44:38

标签: php html css mysql

我想并排显示表格的列。在我的代码中,列是动态添加的。我有调用表的方法,当我调用时,它显示为我的要求,但我没有得到如何并排显示它。

在我的代码中,我调用方法2次,第一次正确显示。第二次,它显示在表格下方。我没有改变这一点。

这样打印, In first call of method,

In second call it is displaying like this

但是,我想并排显示它,它应该独立于调用方法,这意味着如果我调用方法5次,它应该一个接一个地显示列。

我的代码是,

<DOCTYPE html>
  <head>
    <link rel="stylesheet" type="text/css" href="">
      <script>
          $(window).on("load resize ", function() {
           var scrollWidth = $('.tbl-content').width() - $('.tbl-content table').width();
           $('.tbl-header').css({'padding-right':scrollWidth});
        }).resize();
      </script>
     </head>

        <body>
            <?php
              include("C:\wamp64\www\DashBoard\Config2.php");
          echo' <div class="tbl-header">
              <table class="data-table" border="1" style="width:60%;">
               <thead style=background-color:lightblue;">
                    <tr>
                        <th colspan=4>Test case id</th>
                        <th colspan=5>Test case description</th>';
                         $ver="select  version_id,version_number from versions1 join releases on releases.release_id=versions1.rel_id where project_id=7;";
                         $ver_query=mysqli_query($db,$ver);
                            while ($r = mysqli_fetch_array($ver_query))  {
                                    $ver_no[]=$r['version_number'];
                                    $ver_id[]=$r['version_id'];
                            }
                        for($a=0;$a<count($ver_no);$a++){   

                            $version_number=$ver_no[$a];
                            $eid=$a+1;
                            //function
                            thead($db,$version_number,$eid);

                            $version_id=$ver_id[$a];
                            //function  
                            tbody($a,$db,$version_id);

                           }
                            function thead($db,$version_number,$eid){
                            $sql = "select total_tc,passed,failed,blocked,(total_tc-passed-failed-blocked) as notrun from ( select count(tc_id) as total_tc from testcases1 where testcases1.pro_id=7)as tab,(select count(tc_result) as passed from executions1 join releases on releases.release_id=executions1.release_id where tc_result='p' and pro_id=7 and version_eid='$eid' and release_number='1.0') as tab2, (select count(tc_result) as blocked from executions1 join releases on releases.release_id=executions1.release_id where tc_result='b' and pro_id=7 and version_eid='$eid' and release_number='1.0') as tab3, (select count(tc_result) as failed from executions1 join releases on releases.release_id=executions1.release_id where tc_result='f' and pro_id=7 and version_eid='$eid' and release_number='1.0') as tab4;";
                            $query=mysqli_query($db,$sql);
                            while ($row = mysqli_fetch_array($query))  {
                            echo'<th colspan=5>'.$version_number.'(';

                                echo '
                                        '.$row['passed'].',
                                        '.$row['failed'].',
                                        '.$row['blocked'].',
                                        '.$row['notrun'].'';

                            }//while ends
                            echo')</th>';
                        }//thead ends               
                    echo'</tr>
                </thead>
          <tbody>';

               function tbody($a,$db,$version_id){
               $sql=" select tc_id, tc_summary,tc_result from notruncases where pro_id=7 and (version_id='$version_id' or version_id is null) and (release_id=3 or release_id is null);";       
               $query = mysqli_query($db, $sql);    
                while ($row = mysqli_fetch_array($query))
                {
                    echo '<tr>';
                            if($a==0){
                                echo '<td colspan=4> BL -'.$row['tc_id'].'</td>';
                                echo '<td colspan=5>'.$row['tc_summary'].'</td>';
                            }
                            if($row['tc_result']=="p"){
                            echo '<td colspan=5 Style="color:green">Passed</td>';
                             }
                            if($row['tc_result']=="f"){
                            echo '<td colspan=5 Style="color:red">Failed</td>';
                             }
                            if($row['tc_result']=="b"){
                            echo '<td colspan=5 Style="color:blue">Blocked</td>';
                            }
                            if($row['tc_result']==null){
                            echo '<td colspan=5>Not run</td>';

                            }
                        echo '</tr>';


                    }
                }
                ?>
        </tbody>
      </table>

</html>

0 个答案:

没有答案