dongmangsha7354 2018-11-16 06:58
浏览 62

如何在我的分页页面上添加复选框,从数据库生成?

Sorry to bother but I have some curiosity over to how to do checkbox on my pagination page. Now, I'm sure that this must be really easy to do but I couldn't grasp the method at all although I have done few readings and trial and error on some of the available codes online like: Submit Checkbox Value, Fetch data from database as checkbox, checkbox in pagination and many more.

So...I want to ask anyone here if they can give me guidance on how to do this right.

Here is my candidate.php

<script>
  function Pagination() {
    $("#pagination").twbsPagination({
      totalPages: <?php echo $total_pages; ?>,
      visible: 5,
      onPageClick: function (e, page) {
        e.preventDefault();
        $("#target-content").html("loading....");
        $("#target-content").load("candidatepagination.php?page="+page);
      }
    });
  }
</script>

<script>
  $(function () {
      Pagination();
  });
</script>

<script>
  $("#searchBtn").on("click", function(e) {
    e.preventDefault();
    var searchResult = $("#searchBar").val();
    var filter = "searchBar";
    if(searchResult != "") {
      $("#pagination").twbsPagination('destroy');
      Search(searchResult, filter);
    } else {
      $("#pagination").twbsPagination('destroy');
      Pagination();
    }
  });
</script>

<script>
  $(".experienceSearch").on("click", function(e) {
    e.preventDefault();
    var searchResult = $(this).data("target");
    var filter = "experience";
    if(searchResult != "") {
      $("#pagination").twbsPagination('destroy');
      Search(searchResult, filter);
    } else {
      $("#pagination").twbsPagination('destroy');
      Pagination();
    }
  });
</script>

<script>
  $(".citySearch").on("click", function(e) {
    e.preventDefault();
    var searchResult = $(this).data("target");
    var filter = "city";
    if(searchResult != "") {
      $("#pagination").twbsPagination('destroy');
      Search(searchResult, filter);
    } else {
      $("#pagination").twbsPagination('destroy');
      Pagination();
    }
  });
</script>

<script>
  function Search(val, filter) {
    $("#pagination").twbsPagination({
      totalPages: <?php echo $total_pages; ?>,
      visible: 5,
      onPageClick: function (e, page) {
        e.preventDefault();
        val = encodeURIComponent(val);
        $("#target-content").html("loading....");
        $("#target-content").load("search.php?page="+page+"&search="+val+"&filter="+filter);
      }
    });
  }
</script>
 <section id="candidates" class="content-header">
      <div class="container">
        <div class="row">
          <div class="col-md-3">
            <div class="box box-solid">
              <div class="box-body no-padding">
                
                
                    
              </div>
            </div>
          </div>
          <div class="col-md-9">

          <?php

          $limit = 4;

          $sql = "SELECT COUNT(id_user) AS id FROM users";
          $result = $conn->query($sql);
          if($result->num_rows > 0)
          {
            $row = $result->fetch_assoc();
            $total_records = $row['id'];
            $total_pages = ceil($total_records / $limit);
          } else {
            $total_pages = 1;
          }

          ?>

          
            <div id="target-content">
              
            </div>
            <div class="text-center">
              <ul class="pagination text-center" id="pagination"></ul>
            </div> 



          </div>
        </div>
      </div>
    </section>

here is where the query will fetch the data from database and displayed it so users can look at the candidate and choose suitable candidate for them.

and here is my candidatepagination.php

<?php

session_start();

require_once("db.php");

$limit = 4;

if(isset($_GET["page"])){
    $page = $_GET['page'];
}else {
    
    $page=1;
}

    $start_from = ($page-1) * $limit;
    
    $sql = "SELECT * FROM users LIMIT $start_from, $limit";
    $result = $conn-> query($sql);
    
    if($result->num_rows > 0){
        while($row = $result -> fetch_assoc ()) {?>
        
        <div class="attachment-block clearfix">
            <img class="attachment-img" src="uploads/office/britay.png" alt="Attachment Image">
                <div class="attachement-pushed">
                <div class="attachement-text">
                    <div><strong>BA<?php echo $row['id_user']; ?></strong></div>
                </div>
                    <div><?php echo $row['aboutme'] ?></div>
                </div>
        </div>
        <?php
        }
        
    }
$conn->close();

so, can anyone tell me where should I put the checkbox and how can the checkbox be saved into the database?

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大