doulao3078 2017-07-03 13:57
浏览 23

与其他下拉列表php mysql链接时,无法为分页中的页面选择条目数

Am having 500 records in table am having pagination as showing 100 per page or 200 per page. Am having filter dropdown for category. At first when I select category dropdown for filtering its showing correct data am showing 100 entries for each page by default. I am having 200 records of a particular category so I selected 200 entries then selected category gone from dropdown and its showing all records. I have used two seperate forms for entries and category filter.

 <div>
             <?php
                // put all your options into an array
              $options = array(0 => 'Select Entries', 500 => 500, 1000 => 1000, 2000 => 2000, 3000=>3000);
             ?>
                <form enctype="multipart/form-data" method="post" action="" style="padding-bottom:10px;" >
                 <select class="selectpicker" name="results" onchange="this.form.submit();">
                 <?php
                    // loop trough the elements
                  foreach($options as $value => $label) {
                      // test if the current value is the posted one...
                          $selected = (isset($_POST['results']) && intval($_POST['results']) === $value) ? ' selected="selected"' : ''; 
                          echo '<option value="'.$value.'"'.$selected.'>'.$label.'</option>';
                     }
                 ?>
                 </select>
              </form>
            </div>
             <div style="padding-left:200px;">
                 <button>Export</button>
             </div>
            <div style="padding-left:200px;">
               <?php
                // put all your options into an array
                 $filters = array(0 => 'Select based', 1 => 'Pending', 2 => 'Completed');
                ?>
                <form enctype="multipart/form-data" method="post" action="" style="padding-bottom:10px;" >
                 <select class="selectpicker" name="filter_results" onchange="this.form.submit();">
                 <?php
                    // loop trough the elements
                  foreach($filters as $value => $label) {
                      // test if the current value is the posted one...
                          $selected = (isset($_POST['filter_results']) && intval($_POST['filter_results']) === $value) ? ' selected="selected"' : ''; 
                          echo '<option value="'.$value.'"'.$selected.'>'.$label.'</option>';
                     }
                 ?>
                 </select>
              </form> 
            </div>
   $page_id = isset($_GET['page']) ? $_GET['page'] : false;
                       if(isset($_POST['results']))
                       {
                           $results_per_page = $_POST['results'];

                       }
                        else
                           {
                                $results_per_page = 500;

                            }
                          if(!empty($_POST["filter_results"])) {
                              $filters_1 = $_POST['filter_results'];
                              $query="SELECT * FROM video_data WHERE filter_results = $filters_1";
                         }
                          else
                          {
                             $query="SELECT * FROM video_data"; 
                          }

                        $select_categories=mysqli_query($connection,$query);
                        $number_of_categories = mysqli_num_rows($select_categories);
                        $number_of_pages = ceil($number_of_categories/$results_per_page);
                         // determine which page number visitor is currently on
                         if (!isset($_GET['page'])) {
                                   $page = 1;
                          } else {
                            $page = $_GET['page'];
                             }
                        $this_page_first_result = ($page-1)*$results_per_page;
                         if(!empty($_POST["filter_results"])) {
                              $filters_1 = $_POST['filter_results'];
                              $sql='SELECT * FROM  video_data WHERE filter_results ='. $filters_1.' ORDER BY id DESC  LIMIT ' . $this_page_first_result . ',' .  $results_per_page;
                         }
                         else
                         {
                              $sql='SELECT * FROM  video_data ORDER BY id DESC  LIMIT ' . $this_page_first_result . ',' .  $results_per_page;
                         }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法