Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is my view file
- friends_find_view.php
- <link rel="stylesheet" href="<?=base_url()?>css/friends.css" type="text/css" media="all" />
- <div class="shell" >
- <!-- main -->
- <div id="main" style="width:760px">
- <div id='friend_display'>
- <?php if($list->num_rows() > 0 ){
- foreach($list->result() as $show){ ?>
- <!-- image box -->
- <div class="image-box" style="margin-left:30px" id='image-holder' >
- <div class="photo-cover">
- <img width="160px" height="117px" src="<?=base_url()?>uploads/user_images/friends/<?php echo $show->user_image;?>" alt="" />
- </div>
- <p class="photo-name"><b><?php echo $show->user_name;?></b></p>
- <!-- end photo name -->
- </div>
- <?php } } else { echo '<div align="center" style="color:#FF0000; font-size:17px; font-weight:bold">You have no Friends yet</div>';}?>
- <!-- end image-box -->
- <div class="cl"> </div>
- </div>
- <!-- end main -->
- </div>
- </div>
- <div class="loading1" id="loading1">Wait a moment... it's loading!</div>
- <div class="loading1" id="nomoreresults">Sorry, no more results....!</div>
- </div>
- <script src="<?=base_url()?>js/libs/jquery-1.7.2.min.js"></script>
- <script type="text/javascript">
- var page_num = 1;
- $(function(){
- $('#friend_display').scrollPagination({
- 'contentPage': '<?=base_url()?>friends/display_friends', // the url you are fetching the results
- 'contentData': {page_num:$('.image-box').size()}, // these are the variables you can pass to the request, for example: children().size() to know which page you are
- 'scrollTarget': $(window), // who gonna scroll? in this example, the full window
- 'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
- 'beforeLoad': function(){ // before load function, you can display a preloader div
- $('#loading1').fadeIn();
- },
- 'afterLoad': function(elementsLoaded){ // after loading content, you can use this function to animate your new elements
- $('#loading1').fadeOut();
- $(elementsLoaded).fadeInWithDelay();
- page_num:$('.image-box').size();
- }
- });
- // code for fade in element by element
- $.fn.fadeInWithDelay = function(){
- var delay = 0;
- return this.each(function(){
- $(this).delay(delay).animate({opacity:1}, 200);
- delay += 100;
- });
- };
- });
- </script>
- /* End View */
- This is controller
- Friends.php
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Friends extends CI_Controller {
- function __construct()
- {
- parent::__construct();
- $this->load->model('friends_model');
- }
- function find_friends($offset=0)
- {
- $friend['list'] = $this->friends_model->find($offset);
- $this->load->view('friends_find_view',$friend);
- }
- function display_friends()
- {
- $offset = $this->input->post('page_num');
- $find = $this->friends_model->find($offset);
- if($find->num_rows() > 0 )
- {
- foreach($find->result() as $show)
- { ?>
- <div class="image-box" style="margin-left:30px" id='image-holder' >
- <div class="photo-cover">
- <img width="160px" height="117px" src="<?=base_url()?>uploads/user_images/friends/<?php echo $show->user_image;?>" alt="" />
- </div>
- <p class="photo-name"><b><?php echo $show->user_name;?></b></p>
- <!-- end photo name -->
- </div>
- <?php } } else { exit; }?>
- <!-- end image-box -->
- <div class="cl"> </div>
- <?php
- }
- }
- /* End Controller */
- This is code for my query to fetch record from model
- function find($offset)
- {
- $this->db->select('*');
- $this->db->from('users');
- $this->db->limit(6,$offset);
- $result = $this->db->get();
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement