如何将计数添加到名称旁边的表中

维罗妮卡

我试图将计数数据显示在表中,所以像第1行中的第1行,第2行中的第2行,第3行中的第4行。不确定如何处理吗,我必须为每行创建一个语句吗?还是我可以一口气做到这一切?

<!DOCTYPE html>
        <html lang="en">
          <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="description" content="">
            <meta name="author" content="">
            <link rel="icon" href="favicon.ico">
            <title>test</title>
            <!-- Bootstrap core CSS -->

            <link href="../css/custom.css" rel="stylesheet">

          </head>
          <body>
            <nav>
        <?php
            /* For the 2 different types of tables */
            $dataArray = array("one"=>"status='Received'", "two"=>"Department='Claims'");
            require_once("../db_connect.php");
            foreach ($dataArray as $i=>$v)
            {
        ?>      
            <a href="#" data-id="<?php echo $i; ?>"> 
        <?php       
                $stmt = $db->prepare ("SELECT COUNT(*) AS rows_cnt FROM receivingrequests WHERE ".$v);
                $stmt->execute();
                while ($row = $stmt->fetch(PDO::FETCH_ASSOC))    {
                echo $row['rows_cnt'];
                }
        ?>
            </a> 
        <?php
            }
        ?>
        </nav>

        <?php
            foreach ($dataArray as $i=>$v)
            {
        ?>
        <div id="<?php echo $i; ?>" class="toggle_content">

        <?php
            //prepared statement with PDO to query the database
            $stmt = $db->prepare("SELECT * FROM receivingrequests WHERE ".$v);
            $stmt->execute();
        ?>

            <?php //start of the while loop ?>
            <?php while( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { ?>
         <table border="1" style="border: thin #000000; table-layout: fixed; width: 100%; background-color: #FFFFFF; display: table;" class="style1">

            <tr> 
                <th style="width:15%; background-color: #000000;color: #FFFFFF;" class="style3">
                <strong>Request#</strong></th>
                <th style="width:15%; background-color: #000000;color: #FFFFFF;" class="style3">
                <strong>Status</strong></th>
                <th style="width:20%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Comments</strong></th>
                <th style="width:10%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Date Requested</strong></th>
                <th style="width:20%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Name</strong></th>
                <th style="width:10%;  background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Department</strong></th>
            <th style="width:10%; background-color: #000000; color: #FFFFFF;" class="style3">
            <strong>VasLblDate</strong></th>
            </tr>
            <tr>
            <?php $id = $row['RequestNumber'];?>
            <?php echo  "<td> <a href='../update.php?id=".$id."'>".$id."</a></td>"; ?>

                <td class="style2" style="width: 62px"><strong><?php echo $row['Status']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['Comments']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['DATEREQUESTED']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['EmpName']; ?></strong></td>
            <td class="style2"><strong><?php echo $row['Department']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['VasLbDate']; ?></strong></td>

            </tr>

            </table>
         <?php } //end of the while loop?>

        </div>
        <?php
            }
        ?>

        <!-- Bootstrap core JavaScript
            ================================================== -->
            <!-- Placed at the end of the document so the pages load faster -->


            <script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>

        <script>
            $( document ).ready(function() {
                $('a').on('click', function() {
                    var div_id = $(this).data('id');

                    $('.toggle_content').hide();
                    $('#' + div_id).toggle();
                });
            });
        </script>



          </body>
        </html>

从这部分是我要进入的表,因此该表有两列,分别是名称和计数

 <nav>

    <?php
        /* For the 2 different types of tables */
        $dataArray = array("one"=>"status='Received'","two"=>"Department='Claims'","three"=>"Department='flat 1'","four"=>"Department='flat 2'","Five"=>"Department='Inbound'");
        require_once("../db_connect.php");
         foreach ($dataArray as $i=>$v)

        {
    ?>    

  <a href="#" data-id="<?php echo $i; ?>">  
    <?php       
            $stmt = $db->prepare ("SELECT COUNT(*) AS rows_cnt FROM receivingrequests WHERE ".$v);
            $stmt->execute();
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC))    {
            echo $row['rows_cnt'];
            }
    ?>
        </a> 
    <?php
        }
    ?>  

    </nav>

目前看起来像这样

在此处输入图片说明

我希望它看起来像这样。由于数据未更新,因此忽略了计数

在此处输入图片说明

维罗妮卡

我将表添加到导航下面的数组上方,然后在关闭导航之前将关闭表放进去。以及上面的TR和TD<a href="#" data-id="<?php echo $i; ?>">

<!DOCTYPE html>
        <html lang="en">
          <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="description" content="">
            <meta name="author" content="">
            <link rel="icon" href="favicon.ico">
            <title>test</title>
            <!-- Bootstrap core CSS -->

            <link href="../css/custom.css" rel="stylesheet">

          </head>
          <body>

            <nav>

       <table border='1'>
        <?php
            /* For the 2 different types of tables */
            $dataArray = array("one"=>"status='Received'","two"=>"Department='Claims'","three"=>"Department='flat 1'","four"=>"Department='flat 2'","Five"=>"Department='Inbound'");
            require_once("../db_connect.php");

             foreach ($dataArray as $i=>$v)

            {
        ?>    

    <tr><td>
      <a href="#" data-id="<?php echo $i; ?>"> 
        <?php       

                $stmt = $db->prepare ("SELECT COUNT(*) AS rows_cnt FROM receivingrequests WHERE ".$v);
                $stmt->execute();
                while ($row = $stmt->fetch(PDO::FETCH_ASSOC))    {
                echo $row['rows_cnt'];

      }
        ?>
            </a> 

    </td>
        <td>
       <?php echo$v;?></td>
    </tr>
     <?php
            }
        ?>  
    </table>
        </nav>

        <?php
            foreach ($dataArray as $i=>$v)
            {
        ?>

        <div id="<?php echo $i; ?>" class="toggle_content">

        <?php
            //prepared statement with PDO to query the database
            $stmt = $db->prepare("SELECT * FROM receivingrequests WHERE ".$v);
            $stmt->execute();
        ?>

            <?php //start of the while loop ?>
            <?php while( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { ?>
         <table border="1" style="border: thin #000000; table-layout: fixed; width: 100%; background-color: #FFFFFF; display: table;" class="style1">

            <tr> 
                <th style="width:15%; background-color: #000000;color: #FFFFFF;" class="style3">
                <strong>Request#</strong></th>
                <th style="width:15%; background-color: #000000;color: #FFFFFF;" class="style3">
                <strong>Status</strong></th>
                <th style="width:20%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Comments</strong></th>
                <th style="width:10%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Date Requested</strong></th>
                <th style="width:20%; background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Name</strong></th>
                <th style="width:10%;  background-color: #000000; color: #FFFFFF;" class="style3">
                <strong>Department</strong></th>
            <th style="width:10%; background-color: #000000; color: #FFFFFF;" class="style3">
            <strong>VasLblDate</strong></th>
            </tr>
            <tr>
            <?php $id = $row['RequestNumber'];?>
            <?php echo  "<td> <a href='../update.php?id=".$id."'>".$id."</a></td>"; ?>

                <td class="style2" style="width: 62px"><strong><?php echo $row['Status']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['Comments']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['DATEREQUESTED']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['EmpName']; ?></strong></td>
            <td class="style2"><strong><?php echo $row['Department']; ?></strong></td>
                <td class="style2"><strong><?php echo $row['VasLbDate']; ?></strong></td>

            </tr>

            </table>
         <?php } //end of the while loop?>

        </div>
        <?php
            }
        ?>

        <!-- Bootstrap core JavaScript
            ================================================== -->
            <!-- Placed at the end of the document so the pages load faster -->


            <script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>

        <script>
            $( document ).ready(function() {
                $('a').on('click', function() {
                    var div_id = $(this).data('id');

                    $('.toggle_content').hide();
                    $('#' + div_id).toggle();
                });
            });
        </script>



          </body>
        </html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何将计数添加到bat文件的末尾

来自分类Dev

如何将计数添加到直方图?

来自分类Dev

如何将计数添加到bat文件的末尾

来自分类Dev

如何将计数添加到数组?

来自分类Dev

如何将计数总数列添加到R中的数据帧

来自分类Dev

如何将计数数字添加到数据数组中:Doctrine

来自分类Dev

如何将计算的算法添加到列表中?

来自分类Dev

如何使用XSLT将计数器添加到元素名称

来自分类Dev

将计数器添加到sql表

来自分类Dev

SQL Server:如何将计数添加到嵌套选择

来自分类Dev

SQL Server:如何将计数添加到嵌套的选择查询

来自分类Dev

如何将计数系统添加到随机数发生器?

来自分类Dev

Python:如何将计数器对象添加到数据帧?

来自分类Dev

如何将计数添加到从矩阵绘制的 venneuler 维恩图中

来自分类Dev

SQL将计数(从2个表中)添加到现有选择(3个表中)

来自分类Dev

如何将计算添加到gnome搜索栏?

来自分类Dev

如何将计算字段添加到Django模型

来自分类Dev

如何将计算添加到gnome搜索栏?

来自分类Dev

如何将计算字段添加到 MS Access 中的汇总数据

来自分类Dev

将计数编号/条件添加到计数功能

来自分类Dev

将计数添加到jQuery在PHP foreach中添加的行

来自分类Dev

将计数添加到字典列表中的正确字典中

来自分类Dev

将计数按钮添加到与updateNumericInput交互的闪亮应用程序中

来自分类Dev

将计数字段添加到数据框

来自分类Dev

使用FOR XML PATH将计数添加到根元素

来自分类Dev

MySQL临时表查询-将计算列添加到在select中计算的表中

来自分类Dev

如何将名称添加到在结果窗格中显示的列(无列名称)

来自分类Dev

如何将计算列添加到Django模型的列表页面?

来自分类Dev

如何将计算所得的列添加到Pandas数据框?

Related 相关文章

  1. 1

    如何将计数添加到bat文件的末尾

  2. 2

    如何将计数添加到直方图?

  3. 3

    如何将计数添加到bat文件的末尾

  4. 4

    如何将计数添加到数组?

  5. 5

    如何将计数总数列添加到R中的数据帧

  6. 6

    如何将计数数字添加到数据数组中:Doctrine

  7. 7

    如何将计算的算法添加到列表中?

  8. 8

    如何使用XSLT将计数器添加到元素名称

  9. 9

    将计数器添加到sql表

  10. 10

    SQL Server:如何将计数添加到嵌套选择

  11. 11

    SQL Server:如何将计数添加到嵌套的选择查询

  12. 12

    如何将计数系统添加到随机数发生器?

  13. 13

    Python:如何将计数器对象添加到数据帧?

  14. 14

    如何将计数添加到从矩阵绘制的 venneuler 维恩图中

  15. 15

    SQL将计数(从2个表中)添加到现有选择(3个表中)

  16. 16

    如何将计算添加到gnome搜索栏?

  17. 17

    如何将计算字段添加到Django模型

  18. 18

    如何将计算添加到gnome搜索栏?

  19. 19

    如何将计算字段添加到 MS Access 中的汇总数据

  20. 20

    将计数编号/条件添加到计数功能

  21. 21

    将计数添加到jQuery在PHP foreach中添加的行

  22. 22

    将计数添加到字典列表中的正确字典中

  23. 23

    将计数按钮添加到与updateNumericInput交互的闪亮应用程序中

  24. 24

    将计数字段添加到数据框

  25. 25

    使用FOR XML PATH将计数添加到根元素

  26. 26

    MySQL临时表查询-将计算列添加到在select中计算的表中

  27. 27

    如何将名称添加到在结果窗格中显示的列(无列名称)

  28. 28

    如何将计算列添加到Django模型的列表页面?

  29. 29

    如何将计算所得的列添加到Pandas数据框?

热门标签

归档