PHP Bootstrap 分页缺少控件[已关闭]

0mkxixxg  于 2023-02-28  发布在  PHP
关注(0)|答案(2)|浏览(117)

这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
2天前关闭。
Improve this question
我正在对表分页,但控件没有显示。如果我减少到4列,控件将显示。超过4列,控件将消失。请在下面找到我的代码。
任何帮助都将不胜感激。

<?php
session_start();
error_reporting(0);
include('includes/dbconnection.php');
if (strlen($_SESSION['crmsaid']==0)) {
  header('location:logout.php');
  } else{
    
?>
<!doctype html>
<html class="fixed">
    <head>

        <title>View Incident Record Form</title>
        
        <!-- Web Fonts  -->
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">

        <!-- Vendor CSS -->
        <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
        <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
        <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
        <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/datepicker3.css" />

        <!-- Specific Page Vendor CSS -->
        <link rel="stylesheet" href="assets/vendor/select2/select2.css" />
        <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />

        <!-- Theme CSS -->
        <link rel="stylesheet" href="assets/stylesheets/theme.css" />

        <!-- Skin CSS -->
        <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />

        <!-- Theme Custom CSS -->
        <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">

        <!-- Head Libs -->
        <script src="assets/vendor/modernizr/modernizr.js"></script>

    </head>
    <body>
        <section class="body">

            <!-- start: header -->
            <?php include_once('includes/header.php');?>
            <!-- end: header -->

            <div class="inner-wrapper">
                <!-- start: sidebar -->
                <?php include_once('includes/sidebar.php');?>
                <!-- end: sidebar -->

                <section role="main" class="content-body">
                    <header class="page-header">
                        <h2>View Incident Record Form</h2>
                    
                        <div class="right-wrapper pull-right">
                            <ol class="breadcrumbs">
                                <li>
                                    <a href="dashboard.php">
                                        <i class="fa fa-home"></i>
                                    </a>
                                </li>
                                <li><span>View</span></li>
                                <li><span>IRF</span></li>
                            </ol>
                    
                            <a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
                        </div>
                    </header>

                    <!-- start: page -->
                        <section class="panel">
                            <header class="panel-heading">
                                <div class="panel-actions">
                                    <a href="#" class="fa fa-caret-down"></a>
                                    <a href="#" class="fa fa-times"></a>
                                </div>
                        
                                <h2 class="panel-title">View IRF</h2>
                            </header>
                        
                            <div class="panel-body">    
                                <div class="container-fluid">
                                <table class="datatable-1 table table-bordered table-striped" id="datatable-editable">

                                <thead>
                                    <tr>
                                        <th>Sequence #</th>
                                        <th>IRF No.</th>
                                        <th>Name</th>
                                        <th>Mobile Number</th>
                                        <th>Email</th>
                                        <th>IRF Date</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    
<?php
$sql="SELECT tbluser.FullName,tbluser.MobileNumber,tbluser.Email,tblfir.FIRNo,tblfir.ID,tblfir.Status,tblfir.DateofFIR from tblfir join tbluser on tblfir.UserID=tbluser.ID";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);

$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $row)
{               ?>

                                        <td class="text-center"><?php echo htmlentities($cnt);?></td>
                                        <td class="font-w600"><?php  echo htmlentities($row->FIRNo);?></td>
                                        <td class="font-w600"><?php  echo htmlentities($row->FullName);?></td>
                                        <td class="font-w600"><?php  echo htmlentities($row->MobileNumber);?></td>
                                        <td class="font-w600"><?php  echo htmlentities($row->Email);?></td>
                                        <td class="font-w600">
                                            <span class="badge badge-primary"><?php  echo htmlentities($row->DateofFIR);?></span>
                                        </td>
                                        <?php if($row->Status==""){ ?>

                                        <td class="d-none d-sm-table-cell">
                                        <span class="badge badge-primary"><?php echo "Pending"; ?></span>
                                        </td>
<?php } else { ?>
                                        <td class="d-none d-sm-table-cell">
                                            <span class="badge badge-primary"><?php  echo htmlentities($row->Status);?></span>
                                        </td>
<?php } ?> 

                                         <td class="text-center" class="d-none d-sm-table-cell"><a href="view-fir-details.php?editid=<?php echo htmlentities ($row->ID);?>"><i class="fa fa-eye" aria-hidden="true"></i></td>

                                        </tr>
                                                                                
                                    <?php $cnt=$cnt+1;}} ?> 
                                    </tbody>
                                </table>
                                </div>
                            </div>
                        </section>
                    <!-- end: page -->
                </section>
            </div>
        </section>

    
        <!-- Vendor -->
        <script src="assets/vendor/jquery/jquery.js"></script>
        <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
        <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
        <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
        <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
        <script src="assets/vendor/magnific-popup/magnific-popup.js"></script>
        <script src="assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>
        
        <!-- Specific Page Vendor -->
        <script src="assets/vendor/select2/select2.js"></script>
        <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
        <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
        
        <!-- Theme Base, Components and Settings -->
        <script src="assets/javascripts/theme.js"></script>
        
        <!-- Theme Custom -->
        <script src="assets/javascripts/theme.custom.js"></script>
        
        <!-- Theme Initialization Files -->
        <script src="assets/javascripts/theme.init.js"></script>

        <!-- Examples -->
        <script src="assets/javascripts/tables/examples.datatables.editable.js"></script>
    </body>
</html><?php }  ?>

我尝试将列数减少到4,分页控件如预期的那样出现。

cgfeq70w

cgfeq70w1#

我通过添加额外的JS块并从我的表中为其分配id来修复这个问题:

<script>
          $(function () {
            $("#example1").DataTable({
              "responsive": true, "lengthChange": true, "autoWidth": false,
              //"buttons": ["copy", "csv", "excel", "pdf", "print"]
              
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
            $('#example2').DataTable({
              "paging": true,
              "lengthChange": false,
              "searching": false,
              "ordering": true,
              "info": true,
              "autoWidth": false,
              "responsive": true,
            });
            
          });
        </script>
z9smfwbn

z9smfwbn2#

正如Cbroe所说,必须在单元格之前打开表行。

<table class="datatable-1 table table-bordered table-striped" id="datatable-editable">
  <thead>
    <tr>
      <th>Sequence #</th>
      <th>IRF No.</th>
      <th>Name</th>
      <th>Mobile Number</th>
      <th>Email</th>
      <th>IRF Date</th>
      <th>Status</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>
    <?php
      $sql="SELECT tbluser.FullName,tbluser.MobileNumber,tbluser.Email,tblfir.FIRNo,tblfir.ID,tblfir.Status,tblfir.DateofFIR from tblfir join tbluser on tblfir.UserID=tbluser.ID";
      $query = $dbh -> prepare($sql);
      $query->execute();
      $results=$query->fetchAll(PDO::FETCH_OBJ);
    
      $cnt=1;
      if ($query->rowCount() > 0)
      {
        foreach($results as $row)
        {
    ?>
      <tr>
        <td class="text-center"><?php echo htmlentities($cnt); ?></td>
        <td class="font-w600"><?php echo htmlentities($row->FIRNo); ?></td>
        <td class="font-w600"><?php echo htmlentities($row->FullName); ?></td>
        <td class="font-w600"><?php echo htmlentities($row->MobileNumber); ?></td>
        <td class="font-w600"><?php echo htmlentities($row->Email); ?></td>
        <td class="font-w600">
          <span class="badge badge-primary"><?php echo htmlentities($row->DateofFIR); ?></span>
        </td>
        <?php if ($row->Status=="") { ?>
          <td class="d-none d-sm-table-cell">
            <span class="badge badge-primary"><?php echo "Pending"; ?></span>
          </td>
        <?php } else { ?>
          <td class="d-none d-sm-table-cell">
            <span class="badge badge-primary"><?php echo htmlentities($row->Status); ?></span>
          </td>
        <?php } ?>
          <td class="text-center" class="d-none d-sm-table-cell">
            <a href="view-fir-details.php?editid=<?php echo htmlentities ($row->ID); ?>">
              <i class="fa fa-eye" aria-hidden="true"></i>
            </a>
          </td>
        </tr>
                                                                                    
        <?php $cnt = $cnt+1; ?>
      <?php } ?>
    <?php } ?>
  </tbody>
</table>

相关问题