<bdo id='euSTo'></bdo><ul id='euSTo'></ul>

      <small id='euSTo'></small><noframes id='euSTo'>

      1. <legend id='euSTo'><style id='euSTo'><dir id='euSTo'><q id='euSTo'></q></dir></style></legend>
      2. <tfoot id='euSTo'></tfoot>
      3. <i id='euSTo'><tr id='euSTo'><dt id='euSTo'><q id='euSTo'><span id='euSTo'><b id='euSTo'><form id='euSTo'><ins id='euSTo'></ins><ul id='euSTo'></ul><sub id='euSTo'></sub></form><legend id='euSTo'></legend><bdo id='euSTo'><pre id='euSTo'><center id='euSTo'></center></pre></bdo></b><th id='euSTo'></th></span></q></dt></tr></i><div id='euSTo'><tfoot id='euSTo'></tfoot><dl id='euSTo'><fieldset id='euSTo'></fieldset></dl></div>

        如果值在 PHP 中相同,则行跨表

        时间:2023-10-04
          <bdo id='2ky1J'></bdo><ul id='2ky1J'></ul>
            <tbody id='2ky1J'></tbody>
        • <legend id='2ky1J'><style id='2ky1J'><dir id='2ky1J'><q id='2ky1J'></q></dir></style></legend>
          • <i id='2ky1J'><tr id='2ky1J'><dt id='2ky1J'><q id='2ky1J'><span id='2ky1J'><b id='2ky1J'><form id='2ky1J'><ins id='2ky1J'></ins><ul id='2ky1J'></ul><sub id='2ky1J'></sub></form><legend id='2ky1J'></legend><bdo id='2ky1J'><pre id='2ky1J'><center id='2ky1J'></center></pre></bdo></b><th id='2ky1J'></th></span></q></dt></tr></i><div id='2ky1J'><tfoot id='2ky1J'></tfoot><dl id='2ky1J'><fieldset id='2ky1J'></fieldset></dl></div>

                  <tfoot id='2ky1J'></tfoot>
                • <small id='2ky1J'></small><noframes id='2ky1J'>

                  本文介绍了如果值在 PHP 中相同,则行跨表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  <?php
                          $id=$_POST['itinerary_id'];
                          $query=mysql_query("select * from tblitinerarydetails where tblid='$id' order by date_of_travel asc");
                          $i = 0;
                          $prevValue = NULL;
                          while($rows=mysql_fetch_array($query)){
                              $date=$rows['date_of_travel'];
                              $mydate = strtotime($date);
                              $newdate = date('F j, Y', $mydate);
                              $activities=$rows['activities'];
                              $time_departure=$rows['time_departure'];
                              $time_arrival=$rows['time_arrival'];
                              $new_time_departure = date('g:i A', strtotime( $time_departure));
                              $new_time_arrival = date('g:i A', strtotime( $time_arrival));
                              $means_of_transportation= $rows['means_of_transportation'];
                              $travelling_allowance = number_format($rows['travelling_allowance'],2);
                              $destination = $rows['destination'];    
                              $i++;
                              echo "<tr>";
                              if ($newdate == $prevValue) {
                                  echo "<td align='left' rowspan='$i'>$prevValue</td>";
                               }
                              $prevValue = $newdate;
                  
                              echo "<td align='left'>$destination</td>";
                              echo "<td align='center'>$new_time_departure</td>";
                              echo "<td align='center'>$new_time_arrival</td>";
                              echo "<td align='center'>$activities</td>";
                              echo "<td align='center'>$means_of_transportation</td>";
                              echo "<td align='right'>$travelling_allowance</td>";
                              echo "</tr>";
                          }
                  ?>
                  

                  如果值相同,我只想在我的表中添加行跨度.让我们这样说:

                  I just want to add rowspan in my table if the values are the same. Let's say like this:

                  我希望 2 月 4 日的所有日期都是分组的,并且只会出现一次(rowspan).

                  I wanted all the dates with February 4 will be group and will occur once only (rowspan).

                  推荐答案

                  Try with jQuery - 
                  
                  <table border=1 id="myTable">
                      <tr>
                          <td>A</td>
                          <td>1</td>
                      </tr>
                      <tr>
                          <td>A</td>
                          <td>2</td>
                      </tr>
                      <tr>
                          <td>b</td>
                          <td>1</td>
                      </tr>
                      <tr>
                          <td>c</td>
                          <td>1</td>
                      </tr>  
                      <tr>
                          <td>c</td>
                          <td>1</td>
                      </tr>
                  </table>
                  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
                  <script>
                      $(document).ready(function() {
                         var span = 1;
                         var prevTD = "";
                         var prevTDVal = "";
                         $("#myTable tr td:first-child").each(function() { //for each first td in every tr
                            var $this = $(this);
                            if ($this.text() == prevTDVal) { // check value of previous td text
                               span++;
                               if (prevTD != "") {
                                  prevTD.attr("rowspan", span); // add attribute to previous td
                                  $this.remove(); // remove current td
                               }
                            } else {
                               prevTD     = $this; // store current td 
                               prevTDVal  = $this.text();
                               span       = 1;
                            }
                         });
                      });
                  </script>
                  

                  输出:

                  这篇关于如果值在 PHP 中相同,则行跨表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP二维数组转HTML 下一篇:将 HTML 表格另存为图像

                  相关文章

                  最新文章

                    <bdo id='8866p'></bdo><ul id='8866p'></ul>
                    <legend id='8866p'><style id='8866p'><dir id='8866p'><q id='8866p'></q></dir></style></legend>

                    <small id='8866p'></small><noframes id='8866p'>

                  1. <tfoot id='8866p'></tfoot>

                    1. <i id='8866p'><tr id='8866p'><dt id='8866p'><q id='8866p'><span id='8866p'><b id='8866p'><form id='8866p'><ins id='8866p'></ins><ul id='8866p'></ul><sub id='8866p'></sub></form><legend id='8866p'></legend><bdo id='8866p'><pre id='8866p'><center id='8866p'></center></pre></bdo></b><th id='8866p'></th></span></q></dt></tr></i><div id='8866p'><tfoot id='8866p'></tfoot><dl id='8866p'><fieldset id='8866p'></fieldset></dl></div>