【发布时间】:2014-03-23 08:06:34
【问题描述】:
这是我的控制器“控制”
public function home()
{
$config = array();
$config["base_url"] = base_url().'control/index';
$config["total_rows"] = $this->pagin_db->record_count();
$config["per_page"] = 10;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["results"] = $this->pagin_db->
fetch_countries($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$this->load->view('header');
$this->load->view('slr');
$this->load->view('index', $data);
$this->load->view('footer');
}
这是我的模型 pagin_db
class Pagin_db extends CI_Model
{
public function __construct() {
parent::__construct();
}
public function record_count() {
return $this->db->count_all("searchf");
}
public function fetch_location($limit, $start) {
$this->db->limit($limit, $start);
$query = $this->db->get("searchf");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
这是我的观点“索引”
<div id="container">
<center>
<div id="content">
<div>
<h1>Countries</h1>
<div id="body">
<table>
<?php
foreach($results as $data) {
echo "<tr><td>".$data->sno."</td><td>".$data->location."</td></tr>";
}
?>
</table>
<p><?php echo $links; ?></p>
</div>
</div>
</div>
</center>
</div>
在这之后,我必须做些什么来添加 ajax 和最后发布的城市,就像 fb 更新一样
别担心这个城市在数据库中最多只有 6 个,所以只有它是可见的
【问题讨论】:
-
认真的吗?首先做你的工作:列出没有 AJAX 的公司列表,然后询问如何对它们进行分页。仅仅要求一个问题的全部代码就像雇佣一个人而不付钱一样。当你展示你尝试过的东西但它不起作用时,问你的问题是什么,你会得到添加
-
真的很抱歉 chococroc 我只是一名学生和我的大学项目之一,我不是任何公司的员工 真的很抱歉只是要求代码,因为我不知道从哪里开始代码本身并做没有与 codeigniter 有什么关系,所以只有当你有任何链接可以学习如何在没有 ajax 的情况下创建分页时,请发给我,如果我有任何疑问,我会尝试,我会在这里问
-
XD,好的,别担心,但你做这个问题的方式不符合 SO 的规则。我的建议:首先,创建一个没有 AJAX 和分页的普通页面:sitepoint.com/pagination-with-codeigniter 当你拥有它时,你将能够添加 JS 来制作一个无限滚动,当你点击底部时加载每个页面这页纸。这样做,然后带着特定代码问题回来,;D
-
谢谢 chocoroc 实施后我会回来的
-
我已经在上面发布了我的问题,请帮助我
标签: php ajax codeigniter pagination