这是我的控制器" Control"
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 update
并且不要担心这个城市在数据库中只有6个,所以只有它可见
答案 0 :(得分:1)
You must have call ajax when user scroll down. here is example
In View
--------
<script>
var track_load = 0;
var loading = false;
$(document).ready(function(){
$(".container").scroll(function(){
if($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight)
{
if(track_load <= total_groups && loading==false)
{
loading = true;
var form_data={
start:track_load,
};
$.ajax({
url: "display_read",
type: "POST",
data: form_data,
success: function(responseText){
$("#your_div_id").append(responseText);
track_load++;
loading = false;
},
complete: function(){
}
});
}
}
});
});
</script>
In Controller
------------
$start=$_POST['start'];
$read=$this->temp_model->fetch_sort_details($start);
for($i=0;$i<count($read);$i++)
{
//here is your feeds
}
In Model
----------
function fetch_read($start) {
$this->db->select("condition");
$this->db->from("tablename");
$this->db->where("condition","apply");
$this->db->order_by("fieldname","desc");
$start1= ($start * 4);
$this->db->limit(4,$start1);
$query=$this->db->get();
return $query->result();
}
May these code helpfull for all other users of stackoverflow...
thanks