codeIgniter 分页 - 不会转到搜索结果的下一个链接

2024-03-06

我正在对搜索结果使用分页。搜索工作完美。搜索后显示前 10 条记录。但是,当我单击“下一步”按钮时,所有内容都会消失并显示一个空白页面。

任何我的代码中可能有问题的想法将不胜感激。

Model

function search_bookings($time, $title, $payment, $start_date, $end_date,$limit, $start, $type) {

        $this->db->select('reservations.*');
        $this->db->from('reservations');
        $this->db->where('is_deleted', '0');
        $this->db->order_by('date_cal',"desc");

         if (!empty($time) && !is_null($time)) {
            $this->db->where('reservations.type', $time);
        }
        if (!empty($payment) && !is_null($payment)) {
            $this->db->where('reservations.advanced_payment_status', $payment);
        }

        if (!empty($title) && !is_null($title)) {
            $this->db->where('reservations.title', $title);
        }

        if (!empty($start_date) && !is_null($start_date)) {
            $this->db->where('reservations.date_cal >=', $start_date);
            $this->db->where('reservations.date_cal <=', $end_date);
        }

         if ($type == 'half') {
            $this->db->limit($limit, $start);
        }
        $query = $this->db->get();
        return $query->result();
    }

控制器

 function search_reservations($start = 0) {
        $reservation_service = new Reservation_service();
        $config = array();

        $config["base_url"] = site_url() . "/dashboard/manage_bookings/";
        $config["per_page"] = 10;
        $config["uri_segment"] = 4;
        $config["num_links"] = 4;

        $time = $this->input->post('type', TRUE);
        $title = $this->input->post('title', TRUE);
        $payment = $this->input->post('payment', TRUE);
        $date_from = $this->input->post('date_from', TRUE);
        $date_to = $this->input->post('date_to', TRUE);
        $searched_results = $reservation_service->search_bookings($time, $title, $payment, $date_from, $date_to, $config["per_page"], $start, 'half');
        $data['search_results'] = $searched_results;
        $config["total_rows"] = count($reservation_service->search_bookings($time, $title, $payment, $date_from, $date_to, $config["per_page"], 0, 'all'));
        $this->pagination->initialize($config);

        $data["links"] = $this->pagination->create_links();

        $this->load->view('body_pages/search_results', $data);
    }

搜索结果查看

<table  class="display table table-bordered table-striped" id="bookings_table">
    <thead>
        <tr>
            <th>#</th>
            <th>Date</th>
            <th>Hall</th>
            <th>Time</th>                               
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $i = 0;
        foreach ($search_results as $result) {
            ?>
            <tr id="bookings_<?php echo $result->id; ?>">
                <td><?php echo ++$i; ?></td>
                <td><?php echo $result->date_cal; ?></td>
                <td><?php if ("RP" == $result->title) { ?><?php
                        echo "Royal Princess Ballroom (Downstairs)";
                    }
                    ?>
                    <?php if ("GK" == $result->title) { ?><?php
                        echo "Grand Kings Ballroom (Upstairs)";
                    }
                    ?>
                </td>
                <td><?php echo $result->type; ?></td>  
                <td align="center">    
                    <a class="btn btn-primary btn-xs" onclick="display_edit_reservation_pop_up(<?php echo $result->id; ?>)"><i class="fa fa-pencil"  title="Update"></i></a>
                    <a class="btn btn-danger btn-xs" onclick="delete_bookings(<?php echo $result->id; ?>)" ><i class="fa fa-trash-o " title="Remove"></i></a>
                </td>
            </tr>
        <?php } ?>

    </tbody>

</table>

<div class="pagination">
    <?php echo $links; ?>
</div>                                          

嘿嗨,请找到下面带有分页类的控制器代码

/* start code of pagination */
        $config                     = array();
        $config["base_url"]         = base_url()."cms/manage_cms";
        if (count($_GET) > 0) $config['suffix'] = '?' . http_build_query($_GET, '', "&");
        if (count($_GET) > 0) $config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        //$page = 0;
        $config["total_rows"]       = count($this->mdl_cms->getAllCmsByCondition($searchindex,$orderField,$orderby,$rowsPerPage,$page,false));

        if($config["total_rows"] < $rowsPerPage){
            $page = 0;
        }
        $config["per_page"]         = $rowsPerPage;
        //$config["uri_segment"]      = 3;
        $config['full_tag_open']    = '<div class="pagination"><ul>';
        $config['full_tag_close']   = '</ul></div><!--pagination-->';

        $config['first_link'] = '&laquo; First';
        $config['first_tag_open'] = '<li class="prev page">';
        $config['first_tag_close'] = '</li>';

        $config['last_link'] = 'Last &raquo;';
        $config['last_tag_open'] = '<li class="next page">';
        $config['last_tag_close'] = '</li>';

        $config['next_link'] = 'Next &rarr;';
        $config['next_tag_open'] = '<li class="next page">';
        $config['next_tag_close'] = '</li>';

        $config['prev_link'] = '&larr; Previous';
        $config['prev_tag_open'] = '<li class="prev page">';
        $config['prev_tag_close'] = '</li>';

        $config['cur_tag_open']     = '<li class="active"><a href="">';
        $config['cur_tag_close']    = '</a></li>';
        $config['num_tag_open']     = '<li class="page">';
        $config['num_tag_close']    = '</li>';

        $this->pagination->initialize($config);  // Load pagination class 


        $usersArr = $this->mdl_cms->getAllCmsByCondition($searchindex,$orderField,$orderby,$rowsPerPage,$page,true); 
        //echo $this->db->last_query(); //die;
        $data["links"] = $this->pagination->create_links(); // Create pagination links

希望它对你有用

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

codeIgniter 分页 - 不会转到搜索结果的下一个链接 的相关文章

随机推荐

  • 如何在实体框架 4.3.1 中禁用迁移?

    有没有办法在 Entity Framework 4 3 1 中禁用迁移 我从项目中删除了迁移文件夹以及数据库中生成的表 但它不起作用 如何删除迁移 如果您不想使用迁移 但同时希望 EF 为您创建数据库 则只需设置正确的数据库初始值设定项 D
  • keras.backend的clear_session()方法没有清理拟合数据

    我正在研究不同类型数据质量的拟合精度结果的比较 好数据 是特征值中没有任何NA的数据 坏数据 是特征值中具有 NA 的数据 坏数据 应该通过一些值修正来修复 作为值修正 它可能会用零或平均值替换 NA 在我的代码中 我尝试执行多个拟合过程
  • 为什么这是一个最终递归可变参数宏?

    以下构造在 VisualStudio 2013 中进行编译 我刚刚创建了一个新的 consoleApplication 项目 并且仅更改了主 cpp 因此您只需粘贴它并尝试一下即可 它显然所做的是创建一个最终递归可变参数宏 include
  • Python 代码:几何布朗运动 - 出了什么问题?

    我对 Python 还很陌生 但是对于大学论文 我需要应用一些模型 最好使用 Python 我花了几天时间处理我附加的代码 但我真的帮不上忙 出了什么问题 它没有创建一个看起来像带有漂移的标准布朗运动的随机过程 我的参数 如 mu 和 si
  • Windows 通用项目不支持 VS2017 页面

    从昨天开始我遇到了一个相当不愉快的问题 我清除了 NuGet 缓存 因为我无法让 NuGet 包与我的代码之一一起使用 但这没有帮助 反而搞砸了我之前编写的 UWP 应用程序 我的代码中的每个元素都会出现错误 如下所示 在 XAML 中 主
  • PostgreSQL中如何实现嵌套INSERT语句?

    我有两张桌子 group and groupmembers 在插入行时group表 我还想插入两个值 groupid 来自组表的 ID 和userid 创建该组的用户的 ID 到groupmembers桌子 这些是表格 CREATE TAB
  • 如何将根(裸)域重定向到 www - heroku 和 zerigo

    我有一个域 example com 和 www example com 我正在使用 Heroku 和 Zerigo 作为 DNS 现在我有一个从我的 Hostgator 帐户从根域到 www example com 的转发 但这不起作用 我
  • python 的 swig 类型映射:输入和输出数组

    我想在 Python 中使用一个 C 函数 extern int convertAtoB stateStruct myStruct const double PointA 3 double PointB 3 使用 SWIG 我想我需要定义一
  • Web API 2 和 .NET 4.5.1 迁移后 GlobalConfiguration.Configure() 不存在

    我最近开始关注本指南 http www asp net mvc tutorials mvc 5 how to upgrade an aspnet mvc 4 and web api project to aspnet mvc 5 and w
  • Flutter - BloC Cubit 函数不发出状态

    我正在创建一个 Flutter 应用程序 我在项目中添加了一个 BloC 以管理状态 我创建了一个包含数据的列表 我想使用 添加 按钮手动将项目添加到 ListView 我写了一段代码 我的物品 肘节 class ItemCubit ext
  • 如何在 Alembic 迁移中使用现有的 sqlalchemy 枚举 (Postgres)

    在过去的某个时候 我运行了一次 alembic 迁移 它创建了一个users桌子像 def upgrade op create table users sa Column id sa Integer autoincrement True n
  • Eclipse RCP 和 tycho - 无法解析 org.eclipse.swt.widgets.Button 类型。它是从所需的 .class 文件间接引用的

    情况 我有一个 Eclipse RCP 应用程序 我正在尝试使用 Eclipse 的 tycho 插件构建它 当我在 IDe 内执行 Eclipse 应用程序时 应用程序正常执行 当使用 tycho 构建应用程序时 抛出以下错误 The t
  • Linq2Sql 检索数据点

    我目前正在开发一个使用 linq2sql 作为数据库访问框架的项目 现在有很多 linq 查询 它们基本上执行以下操作 var result from
  • R tm包:utf-8文本

    我想为 utf 8 中的非英语文本创建一个词云 实际上 它是哈萨克语 文本在 tm 包的检查功能中显示得绝对正确 但是 当我搜索词频时 所有内容都显示不正确 问题在于文本显示为编码字符而不是单词 西里尔字符显示正确 结果 词云变得一团糟 是
  • 使用 Simplepie 时出现弃用错误

    我已经安装了最新的 Simplepie 代码 1 2 1 并且我正在使用他们提供的演示代码
  • 有没有办法在另一种形式上显示一种形式的一部分?

    我有一个表格 我想做的就是在另一个表单上显示该表单的一部分 我不希望它发挥作用或任何东西 我基本上只是希望它是一张图片 这可能吗 如果可能的话 如何实现 Like display new display form new rectangle
  • 具有动态形状的变量 TensorFlow

    我需要在 TensorFlow 中创建一个矩阵来存储一些值 诀窍是矩阵必须支持动态形状 我正在尝试做与 numpy 中相同的事情 myVar tf Variable tf zeros x y validate shape False whe
  • python 中的“in”和“not in”语句如何工作

    我主要学习 C 语言 并花了很多时间了解其底层实现 但我最近开始学习Python 所以这里有很多与C不同的怪癖 python 中的 in 语句如何工作 if x in array the usage of an in statement p
  • 在 C 编程中将用户输入写入文件

    我正在开发一个程序 将用户输入写入文件 然后搜索文件中的特定记录并将其输出到屏幕 我尝试使用 fgets 和 fputs 但没有成功 这是我到目前为止所拥有的 include
  • codeIgniter 分页 - 不会转到搜索结果的下一个链接

    我正在对搜索结果使用分页 搜索工作完美 搜索后显示前 10 条记录 但是 当我单击 下一步 按钮时 所有内容都会消失并显示一个空白页面 任何我的代码中可能有问题的想法将不胜感激 Model function search bookings