gpt4 book ai didi

php - 使用 Web 服务的 Codeigniter 分页

转载 作者:搜寻专家 更新时间:2023-10-31 21:36:06 26 4
gpt4 key购买 nike

所以我想知道在使用 Web 服务时是否可以使用 Codeigniter 的分页功能?我们正在使用 REST,并且由于我们本身没有连接到数据库,我想知道我将如何处理分页设置中所需的总行数调用?

最佳答案

这就是我设法实现它的方式:

//My array to hold the envelope data
$displayArray = $data['response']['envelopes'];

// The pagination controller code
$quantity = 15;
$start = $this->uri->segment(3);
$data['displayArray'] = array_slice($displayArray,$start,$quantity);
$config['base_url'] = 'http://mysite.com/lcb/status/index/';
$config['total_rows'] = count($displayArray);
$config['per_page'] = $quantity;
$this->pagination->initialize($config);
$this->load->view('envelope_status', $data);

// Code for view
<?php $this->load->view('includes/header'); ?>

<div id="container">
<h1>History</h1>
<?php echo $this->pagination->create_links(); ?>
<table>
<tr><th>Envelope ID</th><th>Status</th><th>Date</th></tr>
<?php
foreach ($displayArray as $envelope) { ?>
<tr cellpadding="2"><td style="text-transform: uppercase;"><?php echo $envelope["envelopeId"]; ?></td><td><?php echo $envelope["status"]; ?></td><td><?php echo $envelope["statusChangedDateTime"]; ?></td></tr>
<?php } ?>
</table>
</div>
<?php $this->load->view('includes/footer'); ?>

就是这样。我仍然需要看看如何让它以最新到最旧的顺序显示它们,而不是相反,但它有效!

关于php - 使用 Web 服务的 Codeigniter 分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169691/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com